Пример #1
0
  /**
   * Create a new {@link WiktionaryEntry} based on the current context. This method always creates a
   * new entry. Use {@link #findEntry(ParsingContext)} if you want to use existing entries (which is
   * usually the case).
   */
  public WiktionaryEntry createEntry(final ParsingContext context) {
    ILanguage language = context.getLanguage();
    PartOfSpeech partOfSpeech = context.getPartOfSpeech();
    String header = context.getHeader();

    WiktionaryEntry entry = context.getPage().createEntry();
    entry.setWordLanguage(language);
    entry.addPartOfSpeech(partOfSpeech);
    if (header != null) entry.setHeader(header);
    entry.setWordEtymology(context.getEtymology());
    return entry;
  }
Пример #2
0
  /**
   * Checks if the current page contains a {@link WiktionaryEntry} matching for the current context
   * (part of speech, language, etc.) and returns it. If no entry could be found, a new one is
   * created (using {@link #createEntry(ParsingContext)}).
   */
  public WiktionaryEntry findEntry(final ParsingContext context) {
    ILanguage language = context.getLanguage();
    PartOfSpeech partOfSpeech = context.getPartOfSpeech();

    List<WiktionaryEntry> posEntryList =
        context
            .getPage()
            .entries()
            .stream()
            .filter(entry -> PartOfSpeech.equals(partOfSpeech, entry.getPartOfSpeech()))
            .filter(entry -> Language.equals(language, entry.getWordLanguage()))
            .collect(Collectors.toList());
    //		List<WiktionaryEntry> posEntryList = word.getPosEntries(partOfSpeech, language);

    if (posEntryList.size() == 0) {
      WiktionaryEntry entry = createEntry(context);
      context.getPage().addEntry(entry);
      return entry;
    } else return posEntryList.get(posEntryList.size() - 1);
  }
Пример #3
0
 public void fillContent(final ParsingContext context) {
   // Add the interwiki link to the current page.
   if (language != null) context.getPage().addInterWikiLink(language);
 }