JWI

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使用例子

public static void 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"

相關搜尋

熱門詞條

聯絡我們