2

When retrieving semantic relations of a Synset through MIT Java Wordnet Interface (JWI) I simply can't get derivationally related forms. I'm using the ISynset class method getRelatedSynsets(IPointer p), but the list simply returns empty.

As a simple test I developed a class that iterates all Noun Synsets of wordnet and tries to find any synset exposing a Derivationally related form. Surprisingly the code can't find a single synset with that relation. Here is the code:

public class DerivationallyTest {

    private static IDictionary dict = null;

    public static void main(String[] args) throws IOException {
        IDictionary dict = dicitionaryFactory();
        Iterator<ISynset> it = dict.getSynsetIterator(POS.NOUN);
        while(it.hasNext()){
            ISynset synset = it.next();
            if(synset.getRelatedSynsets(Pointer.DERIVATIONALLY_RELATED).size() > 0){
                System.out.println("FOUND ONE!!!");
            }
        }
    }



    public static IDictionary dicitionaryFactory() throws IOException{
        if(dict == null){
            System.out.println("Instanciando Dicionario...");
            // 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
            dict = new Dictionary(url); 
            dict.open();
        }
        return dict;
    }
}

Am I doing something wrong or is this an actual bizarre behavior? I have developed a lot of classes using MIT JWI already and wouldn't like to have to change to another API after som much work.

I'm using Wordnet 3.1 and MIT JWI 2.2.3 under Ubuntu 12 LTS

UPDATE: I also tried with Wordnet 3.0 and same thing happens.

Felipe Leão
  • 915
  • 2
  • 15
  • 27
  • I'm not sure if that pointer type is associated with syn-sets, or only words/word indices. I'll look into it – etherous May 31 '14 at 02:34
  • Is this a lexical pointer? If so, try IWord.getRelatedWords(IPointer ptr) – etherous May 31 '14 at 02:41
  • Yes, it is. it's a static public atribute from Pointer class, which implements IPointer interface. I tried IWord.getRelatedWords(Pointer.DERIVATIONALLY_RELATED) and indeed I had results. seems like this pointer is only related to words like you said. – Felipe Leão May 31 '14 at 02:42
  • 1
    Cool, then there's your answer. Lexical pointers don't attach to synsets, they attach to words: http://projects.csail.mit.edu/jwi/api/edu/mit/jwi/item/ISynset.html#getRelatedSynsets(edu.mit.jwi.item.IPointer) – etherous May 31 '14 at 02:43

2 Answers2

3

Only semantic pointers attach to synsets. Lexical pointers only attach to words. Try: IWord.getRelatedWords(IPointer ptr)

http://projects.csail.mit.edu/jwi/api/edu/mit/jwi/item/ISynset.html#getRelatedSynsets(edu.mit.jwi.item.IPointer)

etherous
  • 709
  • 4
  • 10
1

As pointed out by @ethereous, Seems that Pointer.DERIVATIONALLY_RELATED is a Lexical pointer, while others like Pointer.HYPERNYM and Pointer.HOLONYM are Semantic pointer. The class I wrote on the question should be re-written to something like the one below.

public class DerivationallyTest {

    private static IDictionary dict = null;

    public static void main(String[] args) throws IOException {
        IDictionary dict = dicitionaryFactory();
        Iterator<ISynset> it = dict.getSynsetIterator(POS.NOUN);
        while(it.hasNext()){
            ISynset synset = it.next();
            //HERE COMES THE CHANGE!!!! (the ".getWords().get(0).getRelatedWords()")
            if(synset.getWords().get(0).getRelatedWords(Pointer.DERIVATIONALLY_RELATED).size()>0){
                System.out.println("FOUND ONE!!!");
            }
        }
    }



    public static IDictionary dicitionaryFactory() throws IOException{
        if(dict == null){
            System.out.println("Instanciando Dicionario...");
            // 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
            dict = new Dictionary(url); 
            dict.open();
        }
        return dict;
    }
}
Felipe Leão
  • 915
  • 2
  • 15
  • 27
  • Did you try printing out the actual words instead of "FOUND ONE!!!"? JWI gets the proper synsets of the related words, but the word itself is missing. It only shows "?" instead of the lemma. – Chthonic Project Apr 15 '15 at 22:03