本文整理汇总了Java中de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage类的典型用法代码示例。如果您正苦于以下问题:Java IWiktionaryPage类的具体用法?Java IWiktionaryPage怎么用?Java IWiktionaryPage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IWiktionaryPage类属于de.tudarmstadt.ukp.jwktl.api包,在下文中一共展示了IWiktionaryPage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWater
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
/***/
public void testWater() throws Exception {
IWiktionaryPage page = parse("water.txt");
IWiktionaryEntry entry;
entry = page.getEntry(0);
assertEquals(Language.ENGLISH, entry.getWordLanguage());
assertEquals(PartOfSpeech.NOUN, entry.getPartOfSpeech());
assertEquals("{{PIE root|en|wed}}\n" +
"From {{etyl|enm|en}} {{m|enm|water|sc=Latn}}, from {{etyl|ang|en}} {{m|ang|wæter||water|sc=Latn}}, from " +
"{{etyl|gem-pro|en}} {{m|gem-pro|*watōr||water}}, from {{etyl|ine-pro|en}} {{m|ine-pro|*wódr̥||water}}.\n" +
"{{rel-top|cognates}}\n" +
"Cognate with {{etyl|sco|-}} {{m|sco|wattir|sc=Latn}}, {{m|sco|watir||water|sc=Latn}}, " +
"{{etyl|frr|-}} {{m|frr|weeter||water|sc=Latn}}, {{etyl|stq|-}} {{m|stq|woater||water|sc=Latn}}, " +
"{{etyl|fy|-}} {{m|fy|wetter||water|sc=Latn}}, {{etyl|nl|-}} {{m|nl|water||water|sc=Latn}}, " +
"{{etyl|nds|-}} {{m|nds|Water||water|sc=Latn}}, {{etyl|de|-}} {{m|de|Wasser|sc=Latn}}, {{etyl|sv|-}} " +
"{{m|sv|vatten||water|sc=Latn}}, {{etyl|is|-}} {{m|is|vatn||water|sc=Latn}}, {{etyl|sga|-}} coin " +
"{{m|sga|fodorne||otters|lit=water-dogs|sc=Latn}}, {{etyl|la|-}} {{m|la|unda||wave|sc=Latn}}, " +
"{{etyl|lt|-}} {{m|lt|vanduõ||water|sc=Latn}}, {{etyl|ru|-}} {{m|ru|вода́||water}}, {{etyl|sq|-}} " +
"{{m|sq|ujë||water|sc=Latn}}, {{etyl|grc|-}} {{m|grc|ὕδωρ||water}}, {{etyl|hy|-}} {{m|hy|գետ||river}}, " +
"{{etyl|sa|-}} {{m|sa|उदन्|tr=udán||wave, water|sc=Deva}}, {{etyl|hit|-}} " +
"{{m|hit|\uD808\uDE7F\uD808\uDC00\uD808\uDEFB|wa-a-tar|sc=Xsux}}.\n" +
"{{rel-bottom}}",
entry.getWordEtymology().getText());
}
示例2: testIt_s
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
/***/
public void testIt_s() throws Exception {
/*BufferedReader r = new BufferedReader(
new InputStreamReader(new FileInputStream(
new File("src/test/resources/articles-en/it_s.txt")),
"UTF-8"));
String line;
while ((line = r.readLine()) != null)
System.out.println(line);
r.close();
System.out.println();
System.out.println();*/
IWiktionaryPage page = parse("it_s.txt");
Iterator<? extends IWiktionaryEntry> entryIter = page.getEntries().iterator();
assertEntry(Language.ENGLISH, PartOfSpeech.CONTRACTION, 2, entryIter.next());
assertFalse(entryIter.hasNext());
}
示例3: testGetExamples
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
public void testGetExamples() throws Exception {
IWiktionaryPage page = parse("cheio.txt");
final IWiktionaryEntry entry = page.getEntry(0);
final List<IWiktionaryExample> examples = entry.getExamples();
assertEquals(4, examples.size());
final IWiktionarySense senseFull = entry.getSense(1);
final IWiktionarySense senseCovered = entry.getSense(2);
final IWiktionarySense senseFedUp = entry.getSense(3);
assertEquals(2, senseFull.getExamples().size());
assertEquals(1, senseCovered.getExamples().size());
assertEquals(1, senseFedUp.getExamples().size());
assertEquals("{{usex|lang=pt|A rua está '''cheia''' de trânsito|The street is full of traffic.}}", senseFull.getExamples().get(0).getText());
assertEquals("{{usex|lang=pt|Estou '''cheio'''.|I'm full (not hungry anymore).}}", senseFull.getExamples().get(1).getText());
assertEquals("A rua está '''cheia''' de óleo.", senseCovered.getExamples().get(0).getText());
assertEquals("The street is covered with oil.", senseCovered.getExamples().get(0).getTranslation().getText());
assertEquals("{{usex|lang=pt|Estou '''cheio''' dele.|I'm fed up with him.}}", senseFedUp.getExamples().get(0).getText());
}
示例4: getSensesForWord
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
public List<IWiktionarySense> getSensesForWord(final String word,
final IWiktionarySenseFilter filter, boolean normalize) {
ensureOpen();
List<IWiktionarySense> result = new ArrayList<>();
if (word == null || word.isEmpty())
return result;
List<IWiktionaryPage> pages = getPagesForWord(word, normalize);
for (IWiktionaryPage page : pages)
for (IWiktionaryEntry entry : page.getEntries())
for (IWiktionarySense sense : entry.getSenses())
if (filter == null || filter.accept(sense))
result.add(sense);
return result;
}
示例5: testKiefer
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
/***/
public void testKiefer() throws Exception {
IWiktionaryPage page = parse("Kiefer.txt");
IWiktionaryEntry entry = page.getEntry(0);
Iterator<IWiktionaryWordForm> actualIter = entry.getWordForms().iterator();
assertWordFormNoun("die Kiefer", GrammaticalCase.NOMINATIVE, GrammaticalNumber.SINGULAR, actualIter.next());
assertWordFormNoun("die Kiefern", GrammaticalCase.NOMINATIVE, GrammaticalNumber.PLURAL, actualIter.next());
assertWordFormNoun("der Kiefer", GrammaticalCase.GENITIVE, GrammaticalNumber.SINGULAR, actualIter.next());
assertWordFormNoun("der Kiefern", GrammaticalCase.GENITIVE, GrammaticalNumber.PLURAL, actualIter.next());
assertWordFormNoun("der Kiefer", GrammaticalCase.DATIVE, GrammaticalNumber.SINGULAR, actualIter.next());
assertWordFormNoun("den Kiefern", GrammaticalCase.DATIVE, GrammaticalNumber.PLURAL, actualIter.next());
assertWordFormNoun("die Kiefer", GrammaticalCase.ACCUSATIVE, GrammaticalNumber.SINGULAR, actualIter.next());
assertWordFormNoun("die Kiefern", GrammaticalCase.ACCUSATIVE, GrammaticalNumber.PLURAL, actualIter.next());
assertFalse(actualIter.hasNext());
entry = page.getEntry(1);
actualIter = entry.getWordForms().iterator();
assertWordFormNoun("Kiefer", null, GrammaticalNumber.SINGULAR, actualIter.next());
assertWordFormNoun("Kiefer", null, GrammaticalNumber.PLURAL, actualIter.next());
assertFalse(actualIter.hasNext());
}
示例6: testPlant
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
/***/
public void testPlant() throws Exception {
IWiktionaryPage page = parse("plant.txt");
IWiktionarySense sense = page.getEntry(1).getSense(3);
Iterator<IQuotation> quotationIter = sense.getQuotations().iterator();
IQuotation quotation = quotationIter.next();
// assertEquals("{{quote-news|year=2011|date=January 15|author=Sam Sheringham|title=Chelsea 2 - 0 Blackburn Rovers|work=BBC|url=http://news.bbc.co.uk/sport2/hi/football/eng_prem/9358426.stm|page=|passage=First Anelka curled a shot wide from just outside the box, then Lampard '''planted''' a header over the bar from Bosingwa's cross. }}", quotation.getSource().getText());
assertNull(quotation.getSource());
assertEquals(1, quotation.getLines().size());
assertEquals("{{quote-news |year=2011 |date=January 15 |author=Sam Sheringham |title=Chelsea 2 - 0 Blackburn Rovers |work=BBC |url=http://news.bbc.co.uk/sport2/hi/football/eng_prem/9358426.stm |page= |passage=First Anelka curled a shot wide from just outside the box, then Lampard '''planted''' a header over the bar from Bosingwa's cross. }}", quotation.getLines().get(0).getText());
assertFalse(quotationIter.hasNext());
sense = page.getEntry(1).getSense(4);
quotationIter = sense.getQuotations().iterator();
quotation = quotationIter.next();
assertEquals("'''2007''', Richard Laymon, ''Savage'', page 118:", quotation.getSource().getText());
assertEquals(1, quotation.getLines().size());
assertEquals("Sarah, she kissed each of her grandparents on the forehead. They were '''planted''' in a graveyard behind the church.", quotation.getLines().get(0).getText());
assertFalse(quotationIter.hasNext());
}
示例7: testWomen
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
/***/
public void testWomen() throws Exception {
IWiktionaryPage page = parse("women.txt");
// printPronunciations(page);
Iterator<? extends IWiktionaryEntry> entryIter = page.getEntries().iterator();
Iterator<IPronunciation> pronIter = entryIter.next().getPronunciations().iterator();
assertPronunciation(PronunciationType.IPA, "/ˈwɪmɪn/", "RP", pronIter.next());
assertPronunciation(PronunciationType.IPA, "/ˈwɪmən/", "US", pronIter.next());
assertPronunciation(PronunciationType.AUDIO, "en-uk-women.ogg", "Audio (UK)", pronIter.next());
assertPronunciation(PronunciationType.RHYME, "ɪmɪn", "", pronIter.next());
assertFalse(pronIter.hasNext());
pronIter = entryIter.next().getPronunciations().iterator();
assertPronunciation(PronunciationType.AUDIO, "zh-wǒmen.ogg", "audio", pronIter.next());
assertPronunciation(PronunciationType.IPA, "[ wo˨˩mən ]", "", pronIter.next());
assertFalse(pronIter.hasNext());
assertFalse(entryIter.hasNext());
}
示例8: testSynonymsJanuar
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
/***/
public void testSynonymsJanuar() throws Exception {
IWiktionaryPage page = parse("Januar.txt");
IWiktionaryEntry entry = page.getEntry(0);
Set<String> expected = new HashSet<>();
expected.add("Jänner");
expected.add("Hartung");
expected.add("Eismonat");
expected.add("Wintermonat");
expected.add("Schneemonat");
expected.add("Wolfsmonat");
List<IWiktionaryRelation> relations = entry.getSense(1).getRelations();
relations.stream()
.filter(relation -> RelationType.SYNONYM == relation.getRelationType())
.forEach(relation -> assertTrue("Invalid relation: " + relation.getTarget(), expected.remove(relation.getTarget())));
assertTrue("Relations missing: " + Arrays.toString(expected.toArray()), expected.isEmpty());
}
示例9: testDerivedTermsKiefer
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
/***/
public void testDerivedTermsKiefer() throws Exception {
IWiktionaryPage page = parse("Kiefer.txt");
IWiktionaryEntry entry = page.getEntry(1);
Set<String> expected = new HashSet<>();
expected.add("Kieferanomalie");
expected.add("Kieferchirurgie");
expected.add("Kiefergelenk");
expected.add("Kieferhöhle");
expected.add("Kieferklemme");
expected.add("Kieferknochen");
expected.add("Kieferorthopädie");
expected.add("Kieferspalte");
expected.add("Kiefersprerre");
List<IWiktionaryRelation> relations = entry.getUnassignedSense().getRelations();
relations.stream()
.filter(relation -> RelationType.DERIVED_TERM == relation.getRelationType())
.forEach(relation -> assertTrue(expected.remove(relation.getTarget())));
assertTrue("Relations missing: " + Arrays.toString(expected.toArray()), expected.isEmpty());
}
示例10: testBass
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
/***/
public void testBass() throws Exception {
IWiktionaryPage page = parse("bass.txt");
// printPronunciations(page);
Iterator<? extends IWiktionaryEntry> entryIter = page.getEntries().iterator();
Iterator<IPronunciation> pronIter = entryIter.next().getPronunciations().iterator();
assertPronunciation(PronunciationType.IPA, "/beɪs/", "", pronIter.next());
assertPronunciation(PronunciationType.SAMPA, "/beIs/", "", pronIter.next());
assertPronunciation(PronunciationType.AUDIO, "en-us-bass-low.ogg", "Audio (US)", pronIter.next());
assertFalse(pronIter.hasNext());
pronIter = entryIter.next().getPronunciations().iterator();
assertPronunciation(PronunciationType.IPA, "/beɪs/", "", pronIter.next());
assertPronunciation(PronunciationType.SAMPA, "/beIs/", "", pronIter.next());
assertPronunciation(PronunciationType.AUDIO, "en-us-bass-low.ogg", "Audio (US)", pronIter.next());
assertFalse(pronIter.hasNext());
pronIter = entryIter.next().getPronunciations().iterator();
// assertPronunciation(PronunciationType.enPR, "/băs/", "", pronIter.next());
assertPronunciation(PronunciationType.IPA, "/bæs/", "", pronIter.next());
assertPronunciation(PronunciationType.SAMPA, "/b{s/", "", pronIter.next());
assertPronunciation(PronunciationType.AUDIO, "en-us-bass.ogg", "Audio (US)", pronIter.next());
assertFalse(pronIter.hasNext());
assertNull(entryIter.next().getPronunciations());
assertFalse(entryIter.hasNext());
}
示例11: testBass
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
/***/
public void testBass() throws Exception {
IWiktionaryPage page = parse("bass.txt");
IWiktionaryEntry entry = page.getEntry(0);
Iterator<IWiktionaryWordForm> actualIter = entry.getWordForms().iterator();
assertWordFormAdjective("bass", GrammaticalDegree.POSITIVE, actualIter.next());
assertWordFormAdjective("more bass", GrammaticalDegree.COMPARATIVE, actualIter.next());
assertWordFormAdjective("most bass", GrammaticalDegree.SUPERLATIVE, actualIter.next());
assertFalse(actualIter.hasNext());
entry = page.getEntry(1);
actualIter = entry.getWordForms().iterator();
assertWordFormNoun("basses", GrammaticalNumber.PLURAL, actualIter.next());
assertFalse(actualIter.hasNext());
entry = page.getEntry(2);
actualIter = entry.getWordForms().iterator();
assertWordFormNoun("bass", GrammaticalNumber.PLURAL, actualIter.next());
assertWordFormNoun("basses", GrammaticalNumber.PLURAL, actualIter.next());
assertFalse(actualIter.hasNext());
}
示例12: parse
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
protected IWiktionaryPage parse(final String fileName, final String title) throws IOException {
StringBuilder text = new StringBuilder();
BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(
new File("src/test/resources/articles-ru/" + fileName)),
"UTF-8"));
String line;
while ((line = reader.readLine()) != null)
text.append(line).append("\n");
reader.close();
WiktionaryPage result = new WiktionaryPage();
result.setTitle(title);
WiktionaryEntryParser parser = new RUWiktionaryEntryParser();
parser.parse(result, text.toString());
return result;
}
示例13: parse
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
protected IWiktionaryPage parse(final String fileName) throws IOException {
StringBuilder text = new StringBuilder();
BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(
new File("src/test/resources/articles-en/" + fileName)),
"UTF-8"));
String line;
while ((line = reader.readLine()) != null)
text.append(line).append("\n");
reader.close();
WiktionaryPage result = new WiktionaryPage();
result.setTitle(fileName.replace(".txt", ""));
WiktionaryEntryParser parser = new ENWiktionaryEntryParser();
parser.parse(result, text.toString());
return result;
}
示例14: testSumo
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
public void testSumo() throws Exception {
// 5 entries with 4 different etymologies, last entry has empty one
IWiktionaryPage page = parse("sumo.txt");
assertEquals(5, page.getEntryCount());
// adj, noun
assertNotNull(page.getEntry(0).getWordEtymology());
assertEquals(page.getEntry(1).getWordEtymology(), page.getEntry(0).getWordEtymology());
// noun
assertNotNull(page.getEntry(2).getWordEtymology());
assertNotEquals(page.getEntry(2).getWordEtymology(), page.getEntry(1).getWordEtymology());
// noun
assertNotNull(page.getEntry(3).getWordEtymology());
assertNotEquals(page.getEntry(3).getWordEtymology(), page.getEntry(2).getWordEtymology());
// verb, no etymology set
assertNull(page.getEntry(4).getWordEtymology());
}
示例15: testSynonymsRainCatsAndDogs
import de.tudarmstadt.ukp.jwktl.api.IWiktionaryPage; //导入依赖的package包/类
/***/
public void testSynonymsRainCatsAndDogs() throws Exception {
IWiktionaryPage page = parse("rain_cats_and_dogs.txt");
IWiktionaryEntry entry = page.getEntry(0);
Iterator<IWiktionaryRelation> iter = entry.getSense(1).getRelations(SYNONYM).iterator();
assertRelation(SYNONYM, "bucket", iter.next());
assertRelation(SYNONYM, "bucket down", iter.next());
assertRelation(SYNONYM, "chuck it down", iter.next());
assertRelation(SYNONYM, "rain buckets", iter.next());
assertRelation(SYNONYM, "rain pitchforks", iter.next());
assertRelation(SYNONYM, "pelt", iter.next());
assertRelation(SYNONYM, "piss down", iter.next());
assertRelation(SYNONYM, "pour", iter.next());
assertRelation(SYNONYM, "stream", iter.next());
assertRelation(SYNONYM, "teem", iter.next());
assertFalse(iter.hasNext());
}