I wanted to add a new synset to Wordnet using the extjwnl library. In order to do this, I wrote the following sample code. After saving, I observe that the new synonym and word do get added, but the semantic pointer created (which identifies the hyponymy relation) is not saved. How do I relate the pointer to the dictionary?
JWNL.initialize(new FileInputStream(propsFile));
Dictionary dictionary = Dictionary.getInstance();
Iterator<Synset> synsets = dictionary.getSynsetIterator(POS.NOUN);
dictionary.edit();
Synset newSynset = new Synset(dictionary, POS.NOUN);
IndexWord newWord = new IndexWord(dictionary, "hublabooboo", POS.NOUN, newSynset);
Synset topmostSynset = synsets.next();
Pointer newPointer = new Pointer(PointerType.HYPONYM, topmostSynset, newSynset);
dictionary.save();
I’d suggest you add pointer to the synset’s list of pointers:
If the pointer is symmetric (like hypernym, which has a mirror one: hyponym), and dictionary.getManageSymmetricPointers() then the reverse pointer (e.g. hyponym) is added automatically.
By the way, by this code Synset topmostSynset = synsets.next(); it looks like you infer that the first returned synset from the synset iterator is the “entity” one. But this is not guaranteed anywhere. This is dictionary-dependent: might work for file-based, but most likely won’t for map-based and unpredictable for database-based.
Source : SourceForge