当前位置: 首页>>代码示例>>Java>>正文


Java PartOfSpeech类代码示例

本文整理汇总了Java中de.tudarmstadt.ukp.jwktl.api.PartOfSpeech的典型用法代码示例。如果您正苦于以下问题:Java PartOfSpeech类的具体用法?Java PartOfSpeech怎么用?Java PartOfSpeech使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PartOfSpeech类属于de.tudarmstadt.ukp.jwktl.api包,在下文中一共展示了PartOfSpeech类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canHandle

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
/**
 * Check if the label of section is a predefined POS label.
 */
public boolean canHandle(final String blockHeader) {
	partOfSpeech = null;
	String posLabel = blockHeader.trim();
	if (!posLabel.startsWith("===") || !posLabel.endsWith("==="))
		return false;

	Matcher matcher = POS_PATTERN.matcher(blockHeader);
	if (!matcher.find())
		return false;

	if (matcher.group(1) != null)
		posLabel = matcher.group(1);
	else
	if (matcher.group(2) != null)
		posLabel = matcher.group(2);
	else
		posLabel = matcher.group(3);

	partOfSpeech = PartOfSpeech.findByName(posLabel, ENEntryFactory.posMap);
	return (partOfSpeech != null);
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:25,代码来源:ENSenseHandler.java

示例2: testBass

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
/***/
public void testBass() throws Exception {
	IWiktionaryPage page = parse("bass.txt");
	IWiktionaryEntry entry;
	
	entry = page.getEntry(0);
	assertEquals(Language.ENGLISH, entry.getWordLanguage());
	assertEquals(PartOfSpeech.ADJECTIVE, entry.getPartOfSpeech());
	assertEquals("{{etyl|it}} {{term|basso||low|lang=it}}, from {{etyl|la}} {{term|bassus||low|lang=la}}.", entry.getWordEtymology().getText());

	entry = page.getEntry(1);
	assertEquals(Language.ENGLISH, entry.getWordLanguage());
	assertEquals(PartOfSpeech.NOUN, entry.getPartOfSpeech());
	assertEquals("{{etyl|it}} {{term|basso||low|lang=it}}, from {{etyl|la}} {{term|bassus||low|lang=la}}.", entry.getWordEtymology().getText());
	
	entry = page.getEntry(2);
	assertEquals(Language.ENGLISH, entry.getWordLanguage());
	assertEquals(PartOfSpeech.NOUN, entry.getPartOfSpeech());
	assertEquals("From {{etyl|enm}} {{term|bas|lang=enm}}, alteration of {{term|bars|lang=enm}}, from {{etyl|ang}} {{term|bærs||a fish, perch|lang=ang}}, from {{proto|Germanic|barsaz|perch\", literally \"prickly fish|lang=en}}, from {{proto|Indo-European|bhars-||bharst-|prickle, thorn, scale|lang=en}}. Cognate with {{etyl|nl|-}} {{term|baars||baars|perch, bass|lang=nl}}, {{etyl|de|-}} {{term|Barsch||perch|lang=de}}. More at {{l|en|barse}}.", entry.getWordEtymology().getText());
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:21,代码来源:ENEtymologyHandlerTest.java

示例3: testPlant

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
/***/
public void testPlant() throws Exception {
	IWiktionaryPage page = parse("plant.txt");		
	IWiktionaryEntry entry;
	
	entry = page.getEntry(0);
	assertEquals(Language.ENGLISH, entry.getWordLanguage());
	assertEquals(PartOfSpeech.NOUN, entry.getPartOfSpeech());
	assertEquals("From {{etyl|la}} {{term|planta|lang=la}}, later influenced by French {{term|plante}}.", entry.getWordEtymology().getText());
	
	entry = page.getEntry(1);
	assertEquals(Language.ENGLISH, entry.getWordLanguage());
	assertEquals(PartOfSpeech.VERB, entry.getPartOfSpeech());
	assertEquals("{{etyl|la}} {{term|plantare|lang=la}}, later influenced by Old French {{term|planter}}.", entry.getWordEtymology().getText());
	
	entry = page.getEntry(2);
	assertEquals("Danish", entry.getWordLanguage().getName());
	assertEquals(PartOfSpeech.VERB, entry.getPartOfSpeech());
	assertNull(entry.getWordEtymology());
	
	entry = page.getEntry(3);
	assertEquals("Dutch", entry.getWordLanguage().getName());
	assertEquals(PartOfSpeech.NOUN, entry.getPartOfSpeech());
	assertEquals("{{etyl|fr|nl}} ''[[plante]]'', from {{etyl|la|nl}} ''[[planta]]''", entry.getWordEtymology().getText());
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:26,代码来源:ENEtymologyHandlerTest.java

示例4: testWater

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的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());
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:26,代码来源:ENEtymologyHandlerTest.java

示例5: testIt_s

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的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());
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:19,代码来源:ENWordLanguageHandlerTest.java

示例6: testMay

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
/***/
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());
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:21,代码来源:ENWordLanguageHandlerTest.java

示例7: testCombinedFilters

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
/***/
public void testCombinedFilters() {
	// Access.
	wkt = new WiktionaryCollection();
	wkt.addEdition(JWKTL.openEdition(wktDE.getParsedData()));
	wkt.addEdition(JWKTL.openEdition(wktEN.getParsedData()));		
	
	WiktionaryEntryFilter filter = new WiktionaryEntryFilter();
	filter.setAllowedWordLanguages(Language.ENGLISH);
	filter.setAllowedPartsOfSpeech(PartOfSpeech.NOUN);
	assertEntries(wkt.getEntriesForWord("place", filter, true), EN_PLACE1);
	filter.setAllowedWordLanguages(Language.ENGLISH);
	filter.setAllowedPartsOfSpeech(PartOfSpeech.VERB);
	assertEntries(wkt.getEntriesForWord("place", filter, true), EN_PLACE2);
	filter.setAllowedWordLanguages(Language.findByName("French"));
	filter.setAllowedPartsOfSpeech(PartOfSpeech.NOUN);
	assertEntries(wkt.getEntriesForWord("place", filter, true), EN_PLACE3);
	filter.setAllowedWordLanguages(Language.findByName("French"));
	filter.setAllowedPartsOfSpeech(PartOfSpeech.WORD_FORM);
	assertEntries(wkt.getEntriesForWord("place", filter, true), EN_PLACE4);
	filter.setAllowedWordLanguages(Language.GERMAN, Language.ENGLISH, Language.findByName("French"));
	filter.setAllowedPartsOfSpeech(PartOfSpeech.NOUN, PartOfSpeech.VERB, PartOfSpeech.ABBREVIATION);
	assertEntries(wkt.getEntriesForWord("place", filter, true), EN_PLACE1,
			EN_PLACE2, EN_PLACE3);
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:26,代码来源:WiktionaryCollectionTest.java

示例8: getPartOfSpeechIndex

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
/**
 * Get the calculation array's PartOfSpeech index. This method is the same
 * as getPOSIndex but should be used for wiki library
 * 
 * @param partOfSpeech
 * @return row or column index for part of speeches calculation index
 * @throws IrrelevantException
 */
private int getPartOfSpeechIndex(PartOfSpeech partOfSpeech)
		throws IrrelevantException {
	switch (partOfSpeech) {
	case NOUN:
		return 0;
	case VERB:
		return 1;
	case ADJECTIVE:
		return 2;
	case ADVERB:
		return 3;
	default:
		throw new IrrelevantException();

	}
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:25,代码来源:CalculatePOSSimilarityWeight.java

示例9: createEntry

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
/** 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;
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:18,代码来源:EntryFactory.java

示例10: saveWikisaurusEntry

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
protected void saveWikisaurusEntry(final WikisaurusEntry wikisaurusEntry,
		boolean allowCaching) {
	// Find the Wiktionary page for this Wikisaurus entry.
	WiktionaryPage page = wiktionaryDB.getPageForWord(wikisaurusEntry.getTitle());
	if (page == null) {
		if (allowCaching)
			entryQueue.add(wikisaurusEntry);
		else
			System.err.println("PAGE NOT FOUND: " + wikisaurusEntry.getTitle());
		return;
	}
	
	// Find the Wiktionary entry within the Wiktionary page.
	for (WiktionaryEntry entry : page.entries()) {
		if (!Language.equals(entry.getWordLanguage(), wikisaurusEntry.getLanguage()))
			continue;
		if (!PartOfSpeech.equals(entry.getPartOfSpeech(), wikisaurusEntry.getPartOfSpeech()))
			continue;
		
		WiktionarySense sense = findMatchingSense(entry, wikisaurusEntry.getSenseDefinition());
		if (sense == null) {
			System.err.println("Unable to find source word sense: " + wikisaurusEntry);
			continue;
		}

		wikisaurusEntry.getRelations().forEach(sense::addRelation);
	}
	
	wiktionaryDB.savePage(page);
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:31,代码来源:WikisaurusArticleParser.java

示例11: WikisaurusEntry

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
/** Instanciates a new entry with the given title, part of speech,
 *  language, and sense definition (optional)*/
public WikisaurusEntry(final String title, final PartOfSpeech partOfSpeech,
		final ILanguage language, final String senseDefinition) {
	this.title = title;
	this.partOfSpeech = partOfSpeech;
	this.language = language;
	this.senseDefinition = senseDefinition;
	this.relations = new HashSet<>();
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:11,代码来源:WikisaurusEntry.java

示例12: WiktionaryEntryFilter

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
/** Shorthand for setting the allowed entry language, word language,
 *  and parts of speech. Invoking this constructor is equivalent to 
 *  using the default constructor and calling the corresponding 
 *  setter methods. */
public WiktionaryEntryFilter(final Set<ILanguage> allowedEntryLanguages,
		final Set<ILanguage> allowedWordLanguages,
		final Set<PartOfSpeech> allowedPartsOfSpeech) {
	this();
	setAllowedEntryLanguages(allowedEntryLanguages);
	setAllowedWordLanguages(allowedWordLanguages);
	setAllowedPartsOfSpeech(allowedPartsOfSpeech);
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:13,代码来源:WiktionaryEntryFilter.java

示例13: setAllowedPartsOfSpeech

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
/** Define the set of parts of speech which are allowed for a 
 * {@link IWiktionaryEntry}. If no tag is specified, the restriction
 * on the parts of speech will be cleared. */
public void setAllowedPartsOfSpeech(final Collection<PartOfSpeech> allowedPartsOfSpeech) {
	clearAllowedPartsOfSpeech();
	if (allowedPartsOfSpeech != null) {
		this.allowedPartsOfSpeech.addAll(allowedPartsOfSpeech);
	}
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:10,代码来源:WiktionaryEntryFilter.java

示例14: testLodka

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
/***/
public void testLodka() throws Exception {
	IWiktionaryPage page = parse("lodka.txt", "лодка");
	IWiktionaryEntry entry;
	
	assertEquals(1, page.getEntryCount());
	entry = page.getEntry(0);
	assertEquals(PartOfSpeech.NOUN, entry.getPartOfSpeech());
	assertEquals(1, entry.getSenseCount());
	assertEquals("водное транспортное средство, небольшое судно, идущее на вёслах, под парусом или на моторной тяге", entry.getSense(1).getGloss().getPlainText());
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:12,代码来源:WikokitParserTest.java

示例15: testWater

import de.tudarmstadt.ukp.jwktl.api.PartOfSpeech; //导入依赖的package包/类
public void testWater() throws Exception {
	IWiktionaryPage page = parse("water.txt");
	IWiktionaryEntry verb = page.getEntries().stream()
			.filter(e -> Language.ENGLISH.equals(e.getWordLanguage()))
			.filter(e -> e.getPartOfSpeech() == PartOfSpeech.VERB).findFirst().get();

	List<IWiktionaryTranslation> translations = verb.getTranslations();
	assertEquals(158, translations.size());

	List<IWiktionaryTranslation> needChecking =
			translations.stream().filter(IWiktionaryTranslation::isCheckNeeded).collect(toList());

	assertEquals(7, needChecking.size());
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:15,代码来源:ENTranslationHandlerTest.java


注:本文中的de.tudarmstadt.ukp.jwktl.api.PartOfSpeech类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。