public void testDid() throws Exception { IWiktionaryPage page = parse("did.txt"); Iterator<? extends IWiktionaryEntry> entryIter = page.getEntries().iterator(); assertEntry(Language.findByName("Translingual"), PartOfSpeech.NUMBER, 1, entryIter.next()); assertEntry(Language.ENGLISH, PartOfSpeech.VERB, 1, entryIter.next()); assertEntry(Language.findByName("Old Welsh"), PartOfSpeech.NOUN, 1, entryIter.next()); assertFalse(entryIter.hasNext()); }
public void testAbele() throws Exception { IWiktionaryPage page = parse("abele.txt"); Iterator<? extends IWiktionaryEntry> entryIter = page.getEntries().iterator(); assertEntry(Language.ENGLISH, PartOfSpeech.NOUN, 1, entryIter.next()); assertEntry(Language.findByName("Novial"), PartOfSpeech.NOUN, 1, entryIter.next()); assertFalse(entryIter.hasNext()); }
public void testBass() throws Exception { IWiktionaryPage page = parse("bass.txt"); Iterator<? extends IWiktionaryEntry> entryIter = page.getEntries().iterator(); assertEntry(Language.ENGLISH, PartOfSpeech.ADJECTIVE, 1, entryIter.next()); assertEntry(Language.ENGLISH, PartOfSpeech.NOUN, 5, entryIter.next()); assertEntry(Language.ENGLISH, PartOfSpeech.NOUN, 1, entryIter.next()); assertEntry(Language.findByName("Romansch"), PartOfSpeech.ADJECTIVE, 1, entryIter.next()); assertFalse(entryIter.hasNext()); }
public void testMay() throws Exception { IWiktionaryPage page = parse("may.txt"); Iterator<? extends IWiktionaryEntry> entryIter = page.getEntries().iterator(); /*while (entryIter.hasNext()) { IWiktionaryEntry e = entryIter.next(); System.out.println(e.getWord() + ":" + e.getPartOfSpeech() + "/" + e.getWordLanguage()); for (IWiktionarySense s : e.getSenses()) System.out.println(" " + s.getIndex() + ": " + s.getGloss()); }*/ assertEntry(Language.ENGLISH, PartOfSpeech.VERB, 4, entryIter.next()); assertEntry(Language.ENGLISH, PartOfSpeech.NOUN, 1, entryIter.next()); assertEntry(Language.ENGLISH, PartOfSpeech.VERB, 1, entryIter.next()); assertEntry(Language.findByName("Crimean Tatar"), PartOfSpeech.NOUN, 1, entryIter.next()); assertEntry(Language.findByName("Kurdish"), PartOfSpeech.NOUN, 1, entryIter.next()); assertEntry(Language.findByName("Mapudungun"), PartOfSpeech.ADVERB, 1, entryIter.next()); assertEntry(Language.findByName("Tagalog"), PartOfSpeech.VERB, 1, entryIter.next()); assertEntry(Language.findByName("Tatar"), PartOfSpeech.NOUN, 1, entryIter.next()); assertFalse(entryIter.hasNext()); }
/** * 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); }