本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}