WordNet-jwi API

Source: Internet
Author: User

WordNet is a library made by Princeton University. You can download it at http://wordnet.princeton.edu. The latest version of Windows is 2.1, which does not seem to have been updated for several years. The installation process is the same as that of General Software. Remember to use the installation directory later. The general installation directory is: C: \ Program Files \ WordNet \ 2.1.

 

Then under the jwi, download link: http://www.mit.edu /~ Markaf/prj/jwi/, you can select the bottom package to download, including manual. Some examples in the PDF document are comprehensive. Latest Version: 2.2.3. Updated on: Feb 25,201 2.

 

Download the jar package of edu. MIT. jwi_2.1.5_jdk in the package, and then import the jar package in the IDE. Create a new Java project in eclipse, right-click your project, and choose build path> configue build path... --> JAVA build path --> libraries --> Add external jars... select the EDU. MIT. jwi_2.1.5_jdk, so that your project contains the MIT library.

 

Then add the installation path of WordNet to the environment variable so that it can be found in the program. The PDF provides the following description:

"In this particle example, the base WordNet directory is assumed to be stored in a system environment variable called wnhome; this may be different on your system. note that the wnhome variable points to the root of the WordNet installation directory and the dictionary data directory "dict" must be appended to this path."

 

After configuration, paste the sample program in the PDF file to debug it.

 

1 package COM. wordNet; 2 3 Import Java. io. *; 4 Import java.net. *; 5 import Edu. MIT. jwi. dictionary; 6 Import Edu. MIT. jwi. idictionary; 7 Import Edu. MIT. jwi. item. *; 8 9 public class hiwordnet {10 public static void main (string [] ARGs) throws ioexception {11 12 // create a URL pointing to the WordNet dictionary directory through the environment variable. 13 string wnhome = system. getenv ("wnhome"); 14 string Path = wnhome + file. separator + "dict"; 15 URL url = new URL ("file", null, PATH); 16 17 // create a dictionary object and open it. 18 idictionary dict = New Dictionary (URL); 19 dict. open (); 20 21 // query the first meaning of the word "money". Note that the parameter of the get function indicates the # meaning. 22 // The parameter after POS indicates the meaning of the part of speech to be selected 23 24 iindexword idxword = dict. getindexword ("money", POS. (n); 25 iwordid wordid = (iwordid) idxword. getwordids (). get (0); 26 iword word = dict. getword (wordid); 27 system. out. println ("ID =" + wordid); 28 system. out. println ("lemma =" + word. getlemma (); 29 system. out. println ("gloss =" + word. getsynset (). getgloss (); 30 31 // The second meaning 32 iwordid wordid2 = (iwordid) idxword. getwordids (). get (1); 33 iword word2 = dict. getword (wordid2); 34 system. out. println (word2.getsynset (). getgloss (); 35 36 // third meaning 37 iwordid wordid3 = (iwordid) idxword. getwordids (). get (2); 38 iword word3 = dict. getword (wordid3); 39 system. out. println (word3.getsynset (). getgloss (); 40} 41}

 

The next step is to compare the semantic similarity between the two concepts.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.