3 Replies - 4072 Views - Last Post: 04 February 2012 - 01:52 AM

#1 erik.price   User is offline

  • D.I.C Lover
  • member icon

Reputation: 486
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Access Wordnet Dictionary with JAWS

Posted 25 October 2009 - 06:57 AM

Description: The API and installation instructions can be found here: http://lyle.smu.edu/~tspell/jaws/ I used this for Mole Day. I got a list of every word in the English language that contained "mol" (grep -i "mol" '/usr/share/dict') and got the definitions of all of themJava API for Wordnet Searching (JAWS) is an API which allows you to search through the Wordnet Dictionary and retrieve definitions, synonyms, antonyms, etc. This snippet will retrieve the definition of a word and write it out to a file
package wordnet;

import edu.smu.tspell.wordnet.*; 
//be sure this package is included or nothing will work 

import java.io.*;
/**
 * @author Erik Price
 * @date October 24 2009
 */
public class Main {
    public static void main(String[] args) {
        //this system property sets the location of the wordnet dictionary. Move it to your needs
        System.setProperty("wordnet.database.dir","C:\Program Files\WordNet\2.1\dict\");
        WordNetDatabase db = WordNetDatabase.getFileInstance();
        //file is the location of the list of words (newline separated) to be defined
        //a good place to get this is grep and a UNIX dictionary
        String file = 
                "C:\Documents and Settings\Erik " +
                "Price\Desktop\Downloads\dictionary.txt";

        Synset[] syn;

        String[] usage;
        //array of strings for usage examples

        String temp = "";
        BufferedReader in = null;
        try {
            DataOutputStream out = new 
                    DataOutputStream(new
                    FileOutputStream("C:\Documents and Settings\Erik Price" +
                    "\Desktop\Downloads\out.txt"));
                    //change this to where ever you want your output to be
            in = new BufferedReader(new FileReader(file));
            while((temp = in.readLine()) != null){
                /*what this entire while loop does:
                 *reads the file line by line and then
                 *saves it in the variable temp
                 *it then finds the definitions for the word
                 *and writes them to the file*/
                syn = db.getSynsets(temp);
                System.out.println("read: " + temp);
                for(int i = 0; i < syn.length; i++)
                {
                    out.writeBytes(temp + " - "); //write [word] -
                    System.out.println("Retrieved definition: "+
                            syn[i].getDefinition());
                    out.writeBytes(syn[i].getDefinition());
                    //write definition to file
                    usage = syn[i].getUsageExamples();
                    if(usage.length > 0) //if an example usage exists
                    {
                        out.writeBytes("ntExample Usage: "); //write it to a file
                        for(int j = 0; j < usage.length; j++)
                        {
                            System.out.println("Example usage: " + usage[j]);
                            //and keep writing it while there are more
                            out.writeBytes(usage[j]+" ");
                        }
                    }
                    //Windows endline. Change to your needs
                    out.writeBytes("rn");
                }
            }
        } catch (Exception ex) {
            System.out.println("Error: " + ex +"nExiting...");
            System.exit(0);
        }


    }
}

//if you have any questions feel free to PM me. I'm considering making this into a short tutorial



Is This A Good Question/Topic? 0
  • +

Replies To: Access Wordnet Dictionary with JAWS

#2 Galadrielle   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 21-July 10

Re: Access Wordnet Dictionary with JAWS

Posted 21 July 2010 - 11:24 PM

hi Eric! i stumbled upon your snippet while googling on jaws....i cant seem to find many sources or examples on usage of jaws and very urgently need to implement a class that will go through list of words and find its synonims in wordnet. But the big point is when there is more synonims for one word i need to get the approximate most probable one. My first try was the prolog database, but only in the end i figured out that from there i can not get these probabilities. Any idea / experience with this???? Would be very grateful!
Was This Post Helpful? 0
  • +
  • -

#3 navin israni   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 19-April 11

Re: Access Wordnet Dictionary with JAWS

Posted 19 April 2011 - 09:50 AM

@galadrielle what you are talking about is called word sense disambiguation..check out for it..
Was This Post Helpful? 0
  • +
  • -

#4 blueprincess1990   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 04-February 12

Re: Access Wordnet Dictionary with JAWS

Posted 04 February 2012 - 01:52 AM

Hi! I am doing my final year project based on Word Net and Lexical Chain. I would like to know how to include this package edu.smu.tspell.wordnet into JCreator. Your prompt answer will be most appreciated. Thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1