Example #1
0
  /**
   * Parses one definition (one line in Russian, several lines in English Wiktionary), i.e. extracts
   * {{label.}}, definition, {{example|Quotation sentence.}}, creates and fills a meaning
   * (WMeaning).
   *
   * @param wikt_lang language of Wiktionary
   * @param page_title word which are described in this article 'text'
   * @param lang_section language of this section of an article
   * @param def_text text of one definition
   * @return WMeaning or null if the line is not started from "#"
   */
  public static WMeaning parseOneDefinition(
      LanguageType wikt_lang, String page_title, LanguageType lang_section, String def_text) {
    WMeaning wm = NULL_WMEANING;

    LanguageType l = wikt_lang;

    if (l == LanguageType.ru) {
      wm = WMeaningRu.parseOneDefinition(page_title, lang_section, def_text);

    } else if (l == LanguageType.en) {
      wm = WMeaningEn.parseOneDefinition(page_title, lang_section, def_text);

      //  return WordEn;
      // } //else if(code.equalsIgnoreCase( "simple" )) {
      //  return WordSimple;

      // todo
      // ...

    } else {
      throw new NullPointerException("Null LanguageType");
    }

    return wm;
  }
Example #2
0
  /**
   * Parses text (related to the POS), creates and fills array of meanings (WMeaning).
   *
   * @param wikt_lang language of Wiktionary
   * @param page_title word which are described in this article 'text'
   * @param lang_section language of this section of an article
   * @param pt POSText defines POS stored in pt.text
   * @return
   */
  public static WMeaning[] parse(
      LanguageType wikt_lang, String page_title, LanguageType lang_section, POSText pt) {
    // === Level III. Meaning ===
    WMeaning[] wm = NULL_WMEANING_ARRAY;

    LanguageType l = wikt_lang;

    if (l == LanguageType.ru) {

      // get context labels, definitions, and quotations... todo
      /*   if(0==wm.length) {
              return NULL_WMEANING_ARRAY;
      }*/
      wm = WMeaningRu.parse(page_title, lang_section, pt);

    } else if (l == LanguageType.en) {
      wm = WMeaningEn.parse(page_title, lang_section, pt);

      // } //else if(code.equalsIgnoreCase( "simple" )) {
      //  return WordSimple;

      // todo
      // ...

    } else {
      throw new NullPointerException("Null LanguageType");
    }

    return wm;
  }