本文整理汇总了Java中edu.mit.jwi.IDictionary.close方法的典型用法代码示例。如果您正苦于以下问题:Java IDictionary.close方法的具体用法?Java IDictionary.close怎么用?Java IDictionary.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.mit.jwi.IDictionary
的用法示例。
在下文中一共展示了IDictionary.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractLastHypernym
import edu.mit.jwi.IDictionary; //导入方法依赖的package包/类
private String extractLastHypernym(Token token) throws IOException {
String result = token.getCoveredText();
String path = "wordnet" + File.separator + "dict";
URL url = new URL("file", null, path);
IDictionary dict = new Dictionary(url);
dict.open();
IIndexWord idxWord = dict.getIndexWord(token.getCoveredText().toLowerCase(), getCorrectPOS(token.getPos()));
if (idxWord != null && idxWord.getWordIDs().size() > 0) {
IWordID wordID = idxWord.getWordIDs().get(0);
IWord word = dict.getWord(wordID);
ISynset synset = word.getSynset();
List<ISynsetID> hypernyms = synset.getRelatedSynsets(Pointer.HYPERNYM);
List<IWord> words;
for (ISynsetID sid : hypernyms) {
words = dict.getSynset(sid).getWords();
for (Iterator<IWord> i = words.iterator(); i.hasNext();) {
result = i.next().getLemma();
}
}
}
dict.close();
return result;
}
示例2: testWordSearch
import edu.mit.jwi.IDictionary; //导入方法依赖的package包/类
public static void testWordSearch() throws IOException{
// construct the URL to the Wordnet dictionary directory
File file =new File("wordnetDB/dict/");
// construct the dictionary object and open it
IDictionary dict = new Dictionary(file) ;
dict.open();
IIndexWord idxWord = dict.getIndexWord ("midnight" , POS.NOUN) ;
if(idxWord == null) System.out.println("no word\n--------\n");
for (IWordID iword: idxWord.getWordIDs()){
System.out.println("offset: " + iword.getSynsetID().getOffset());
IWord word = dict.getWord(iword);
System.out.println("gloss: " + word.getSynset().getGloss());
}
//System.out.println("offset: " + idxWord.getWordIDs().get(0).getSynsetID().getOffset());
dict.close();
}
示例3: testTopic
import edu.mit.jwi.IDictionary; //导入方法依赖的package包/类
public static void testTopic() throws IOException{
// construct the URL to the Wordnet dictionary directory
File file =new File("wordnetDB/dict/");
// construct the dictionary object and open it
IDictionary dict = new Dictionary(file) ;
dict.open();
// look up first sense of the word " dog "
WordnetStemmer ws = new WordnetStemmer(dict);
//dog: 10114209
//car: 2958343
//home: 8559508
//midnight
IWordID wordID1 = new WordID(15168185,POS.NOUN,1);
IWord word1 = dict.getWord(wordID1);
System.out.println("LexFile = " + word1.getSynset().getLexicalFile());
System.out.println("Lemma = " + word1.getLemma());
System.out.println("Gloss = " + word1.getSynset().getGloss()) ;
System.out.print("Synonyms: ");
for(IWord iword : word1.getSynset().getWords())
System.out.print(iword.getLemma() + ", ");
System.out.println("\n-----------------------") ;
System.out.println("related: ") ;
Map<IPointer, List<ISynsetID>> k = word1.getSynset().getRelatedMap();
for(IPointer ip : k.keySet()){
System.out.print(ip.getName() + ": ");
for (ISynsetID isid : k.get(ip)){
System.out.print(isid.getOffset() + ".");
ISynset ss = dict.getSynset(isid);
System.out.print(ss.getPOS() + "=");
IWord iw = dict.getWord(new WordID(ss.getOffset(),ss.getPOS(), 1));
System.out.print(iw.getLemma() + ", ");
}
System.out.println();
}
/*
for(IWordID wordID: idxWord.getWordIDs()){
IWord word = dict.getWord(wordID);
//System.out.println("Sence = " + word.getSenseKey().getLexicalID()) ;
System.out.println("Lemma = " + word.getLemma()) ;
System.out.println("Gloss = " + word.getSynset().getGloss()) ;
System.out.println("Synonyms: ");
for(IWord iword : word.getSynset().getWords())
System.out.print(iword.getLemma() + ", ");
System.out.println("\n-----------------------");
}
*/
dict.close();
}