views:

35

answers:

1

I'm struggling to find whether a word is noun or verb etc

I found the MIT Java Wordnet Interface there was a sample code like this, but when i use this i get error that Dictionary is abstract class and cannot be instantiated

public void testDictionary() throws IOException {


// construct the URL to the Wordnet dictionary directory

String wnhome = System.getenv("WNHOME");

String path = wnhome + File.separator + "dict";

URL url = new URL("file", null, path);

    // 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);

IWordID wordID = idxWord.getWordIDs().get(0);

IWord word = dict.getWord(wordID);

System.out.println("Id = " + wordID);

System.out.println("Lemma = " + word.getLemma());

System.out.println("Gloss = " + word.getSynset().getGloss());

 }

i also got another java interface to wordnet

danbikel's interface

but i dont get answer for the query

WordNet wn=new WordNet("/usr/share/wordnet");
    Morphy m = new Morphy(wn);

    System.out.println(m.morphStr("search","NOUN").length);

Always the string length is 0, what is the correct arguments for this method? here is the javadoc of the method, what am i doing wrong?

public String[] morphStr(String origstr, String pos)
Tries several techniques on origstr to find possible base forms (lemmas).

Specified by:
morphStr in interface MorphyRemote
Parameters:
origstr - word or collocation, separated either by whitespace, '_' or '-', to find lemma of
pos - part of speech of origstr
Returns:
array of possible lemmas for origstr, possibly of length 0 if no lemmas could be found
A: 

I personally recommend Yawni, the new name for the old JWordNet project. To get all the parts-of-speech for a search word, you would call FileBackedDictionary.synsets(yourQueryWord), then iterate through the returned Synsets calling getPOS().

msbmsb
there are no links available to download the soyrce or jar file in the website.. can you please give me link?
karthi
The project is hosted on sourceforge at: http://sourceforge.net/projects/yawni/ . Get the source from: `git clone git://yawni.git.sourceforge.net/gitroot/yawni/yawni`. See also the Developers page: http://www.yawni.org/wiki/Main/Developers
msbmsb