JWI(the MIT Java Wordnet Interface),是一个面向WordNet的Java API类库。JWI支持访问1.6——3.0之间的任意版本的WordNet,也包括其他扩展版本的WordNet。
JWI相关
JWI是由美国麻省理工学院计算机与人工智能实验室的Mark Alan.Finlayson主持的项目,使用Java编写。其目的是为了访问Princeton University 普林斯顿大学主持的WordNet提供方便的Java接口。
JWI开发包中所有的类包都起名为 edu.mit.jwi,是一个免费的开源的工具。当前版本为JWI 2.2.2 。可以到Mark Alan.Finlayson个人主页下载。
JWI提供了在线API文档和随代码下载的API文档。用户可以使用其进行访问WordNet。
JWI也提供了用户使用手册。
JWI使用例子
publicstaticvoid testDitctionary() throws IOException{
// construct the URL to the Wordnet dictionary directory
String wnhome = System. getenv("WNHOME"); //获取环境变量WNHOME
String path = wnhome + File. separator+ "dict";
URL url= new URL("file", null, path); //创建一个URL对象,指向WordNet的ditc目录
// construct the dictionary object and open it
IDictionary dict= new Dictionary(url);
dict.open(); //打开词典
// look up first sense of the word "dog "
IIndexWord idxWord=dict.getIndexWord("dog", POS. NOUN);//获取一个索引词,(dog,名词)
IWordID wordID=idxWord.getWordIDs().get(0);//获取dog第一个词义ID
IWord word = dict.getWord(wordID); //获取该词
System . out . println ("Id = " + wordID );
System . out . println (" 词元 = " + word . getLemma ());
System . out . println (" 注解 = " + word . getSynset (). getGloss ());
}
}
执行得到的结果如下:
Id = WID-02064081-N-??-dog
词元 = dog
注解 = a member of the genus Canis (probably descended from the common wolf) that has been domesticated by man since prehistoric times; occurs in many breeds; "the dog barked all night"