[英]How to use Stanford CoreNLP POS-tags to retrieve synsets from WordNet?
I'm working with Java in Eclipse, & Stanford CoreNLP. 我正在Eclipse和Stanford CoreNLP中使用Java。 I wanna know how to use the POS tags generated by Stanford CoreNLP, to retrieve the synsets of tagged words from WordNet.
我想知道如何使用Stanford CoreNLP生成的POS标签,以从WordNet检索带标签的单词的同义词集。 (I tokenized the sentence before POS-tagging)
(我在POS标记之前标记了该句子)
Since WordNet has POS-tagged synsets, I'm assuming it can be done. 由于WordNet具有POS标记的同义词集,我假设它可以完成。 I looked up a few tutorials as well, but there's nothing much helpful.
我也查阅了一些教程,但是没有什么帮助。
the following code gets all synsets of searchWord+POS tag, then from them prints their glosses. 以下代码获取searchWord + POS标记的所有同义词集,然后从它们打印其光泽。 you can change POS.NOUN to seach other forms of the searchword:
您可以更改POS.NOUN来搜索其他形式的搜索字词:
public int stackoverflow(String searchWord) throws IOException {
String s = null;
IDictionary dict = dicitionaryFactory();
try {
IIndexWord idxWord = dict.getIndexWord(searchWord, POS.NOUN);
for (int i = 0; i < idxWord.getWordIDs().size(); i++) {
IWordID wordID = idxWord.getWordIDs().get(i); // ist meaning
edu.mit.jwi.item.IWord word = dict.getWord(wordID);
edu.mit.jwi.item.ISynset synset = word.getSynset();
List<edu.mit.jwi.item.IWord> words;
System.out.println(synset.getGloss());
}
return -1;
} catch (Exception e) {
return -2;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.