close
使用 Java API 存取 VerbNet 之前,要先安裝 VerbNet:
http://verbs.colorado.edu/verbnet_downloads/downloads.html
如下圖,先點選 "Research & Projects" 並且點 "Downloads",下載 zip file 並且安裝。
之後,來到 MIT 所開發用來存取 VerbNet 的 Java API 網頁:
http://projects.csail.mit.edu/jverbnet/
下載 Binary Files Only 即可。
之後將這個下載的 jar import 到你的 project 中,使用下列的 demo code 就可以存取 VerbNet了。
// make a url pointing to the Verbnet data String pathToVerbnet = "/ path /to/ your / verbnet / directory /"; URL url = new URL (" file ", null , pathToVerbnet ); // construct the index and open it IVerbIndex index = new VerbIndex ( url ); index . open (); // look up a verb class and print out some info IVerbClass verb = index . getRootVerb ("hit -18.1 "); IMember member = verb . getMembers (). get (0) ; Set < IWordnetKey > keys = member . getWordnetTypes (). keySet (); IFrame frame = verb . getFrames (). get (0) ; FrameType type = frame . getPrimaryType (); String example = frame . getExamples (). get (0) ; System . out . println ("id: " + verb . getID ()); System . out . println (" first wordnet keys : " + keys ); System . out . println (" first frame type : " + type . getID ()); System . out . println (" first example : " + example );
結果:
id: hit -18.1
first wordnet keys : [ bang %2:35:00 , bang %2:35:01]
first frame type : NP V NP
first example : Paula hit the ball .
全站熱搜
留言列表