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


Java POS.valueOf方法代码示例

本文整理汇总了Java中edu.mit.jwi.item.POS.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java POS.valueOf方法的具体用法?Java POS.valueOf怎么用?Java POS.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.mit.jwi.item.POS的用法示例。


在下文中一共展示了POS.valueOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWord

import edu.mit.jwi.item.POS; //导入方法依赖的package包/类
@Override
public String getWord(int synset, String pos) {
	try {
		dict.open();
	} catch (IOException e) {
		return "";
	}
	IWordID wordID1 = new WordID(synset,POS.valueOf(pos),1);
	IWord word1 = dict.getWord(wordID1);
	
	String lemma = word1.getLemma();
	
	dict.close();
	
	return lemma;
}
 
开发者ID:kariminf,项目名称:langpi,代码行数:17,代码来源:JWIRequestor.java

示例2: getWords

import edu.mit.jwi.item.POS; //导入方法依赖的package包/类
@Override
public List<String> getWords(int synset, String pos) {
	ArrayList<String> words = new ArrayList<String>();
	
	try {
		dict.open();
	} catch (IOException e) {
		return words;
	}
	
	IWordID wordID1 = new WordID(synset,POS.valueOf(pos),1);
	IWord word1 = dict.getWord(wordID1);
	ISynset isynset = word1.getSynset() ;
	
	for( IWord word : isynset.getWords () )
		words.add(word.getLemma());
		
	return words;
}
 
开发者ID:kariminf,项目名称:langpi,代码行数:20,代码来源:JWIRequestor.java

示例3: getBabelMorphFromDocument

import edu.mit.jwi.item.POS; //导入方法依赖的package包/类
/**
 * Gets a {@link BabelMorphWord} from a {@link Document}
 * 
 * @param doc
 *            a Lucene {@link Document} record for a certain WktMorphWord
 * @return an instance of a {@link BabelMorphWord} from a {@link Document}
 */
public static BabelMorphWord getBabelMorphFromDocument(Document doc)
{
	try
	{
		String queryLanguage = doc.get(BabelMorphIndexField.LANGUAGE.toString());
		Language lang = Language.valueOf(queryLanguage);
		String queryLemma = doc.get(BabelMorphIndexField.LEMMA.toString());
		String queryPos = doc.get(BabelMorphIndexField.POS.toString());
		POS p = POS.valueOf(queryPos);
		String[] queryForms = doc.getValues(BabelMorphIndexField.FORM.toString());
		String[] queryInfos = doc.getValues(BabelMorphIndexField.INFO.toString());
		
		if( lang == null || queryLemma == null || 
				queryPos == null || p == null || queryForms == null ) return null;
			
		HashMultimap<String, String> multimap =  HashMultimap.create();
		for(int i=0;i<queryForms.length;i++)
			multimap.put(queryForms[i], queryInfos[i]);
		
		BabelMorphWord bmw = new BabelMorphWord(queryLemma, lang, p, multimap);
		return bmw;
	
	}
    catch (Exception e)
    {
		e.printStackTrace();
	}
    
    return null;
}
 
开发者ID:raganato,项目名称:BabelMorph,代码行数:38,代码来源:BabelMorph.java

示例4: getLexFileNumber

import edu.mit.jwi.item.POS; //导入方法依赖的package包/类
public int getLexFileNumber(int synset, String pos){
	
	try {
		dict.open();
	} catch (IOException e) {
		return -1;
	}
	
	IWordID wordID1 = new WordID(synset,POS.valueOf(pos),1);
	IWord word1 = dict.getWord(wordID1);
	int number = word1.getSynset().getLexicalFile().getNumber();
	dict.close();
	
	return number;
}
 
开发者ID:kariminf,项目名称:langpi,代码行数:16,代码来源:JWIRequestor.java

示例5: getBabelMorphWord

import edu.mit.jwi.item.POS; //导入方法依赖的package包/类
private  List<BabelMorphWord> getBabelMorphWord(Language language, String lemma, String word, POS pos)throws IOException
{
	BooleanQuery.Builder mainQuery = new BooleanQuery.Builder();
	
	Term termLanguage = new Term(BabelMorphIndexField.LANGUAGE.toString(), language.name());
	TermQuery termQueryLanguage = new TermQuery(termLanguage);
	mainQuery.add(termQueryLanguage, BooleanClause.Occur.MUST);
	
	if( word != null)
	{
		Term termForm =new Term(BabelMorphIndexField.FORM.toString(), word);
		TermQuery termQueryForm = new TermQuery(termForm);
		mainQuery.add(termQueryForm, BooleanClause.Occur.MUST);
	}
	
	if( lemma != null)
	{
		Term termLemma =new Term(BabelMorphIndexField.LEMMA.toString(), lemma);
		TermQuery termQueryLemma = new TermQuery(termLemma);
		mainQuery.add(termQueryLemma, BooleanClause.Occur.MUST);
	}
	
	if( pos != null )
	{
		Term termPos =new Term(BabelMorphIndexField.POS.toString(), pos.name());
		TermQuery temQueryPos = new TermQuery(termPos);
		mainQuery.add(temQueryPos, BooleanClause.Occur.MUST);
	}
	
	List<BabelMorphWord> listBabelMorphWord = new ArrayList<BabelMorphWord>();
	BooleanQuery bq = mainQuery.build();
	TotalHitCountCollector collector = new TotalHitCountCollector();
	morphologicalDictionary.search(bq, collector);
	TopDocs topDocs = morphologicalDictionary.search(bq, Math.max(1, collector.getTotalHits()));
	ScoreDoc[] topScoreDocs = topDocs.scoreDocs;
	for(ScoreDoc sc : topScoreDocs)
	{
		Document doc = morphologicalDictionary.doc(sc.doc);
		
		String queryLemma = doc.get(BabelMorphIndexField.LEMMA.toString());
		String queryPos = doc.get(BabelMorphIndexField.POS.toString());
		POS p = POS.valueOf(queryPos);
		String[] queryForms = doc.getValues(BabelMorphIndexField.FORM.toString());
		String[] queryInfos = doc.getValues(BabelMorphIndexField.INFO.toString());
		SetMultimap<String, String> multimap = HashMultimap.create();
		for(int i=0;i<queryForms.length;i++)
			multimap.put(queryForms[i], queryInfos[i]);	
		
		BabelMorphWord bmw = new BabelMorphWord(queryLemma, language, p, multimap);
		listBabelMorphWord.add(bmw);
	}
	
	return listBabelMorphWord;
}
 
开发者ID:raganato,项目名称:BabelMorph,代码行数:55,代码来源:BabelMorph.java


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