Help Getting Synonyms

  • Ray

    Ray - 2004-11-22

    Hi there,

    I am trying to get synonyms for a given word however sometimes I do not get any results even though WordNet returns some.. Here is my code..

    IndexWord word =

    Synset synset = word.getSense(1);
    PointerTargetNodeList h =

    ...however I'm getting 0 results for this one but WordNet gives a list of results...

    wn amazing -n1 -sysnv gives...
    amaze, astonish, astound => surprise

    Can anyone tell me what's wrong in my code .. and if it is the right way to get synonyms for a given word.

    Thanks for your time

    • leeo

      leeo - 2004-11-22

      have a look at this

      public WNTest(){
               try {
                  // initialize JWNL (this must be done before JWNL can be used)
                  JWNL.initialize(new FileInputStream("file_properties.xml"));
                  IndexWord word = Dictionary.getInstance().lookupIndexWord(POS.VERB,"amazing");

                  Synset synset[] = word.getSenses();
                  for(int i=0;i<=synset.length;i++){
              } catch (Exception ex) {
      all it does is print out the sysnets to string but notice the output shows the Words in there 2
      [Synset: [Offset: 700834] [POS: verb] Words: amaze, astonish, astound -- (affect with wonder; "Your ability to speak six languages amazes me!")]

      u could then use the
      Word[]  getWords()  method of synset
      hope this helps not the best at explaining so gimme a shout if its still unclear

    • leeo

      leeo - 2004-11-22

      oppps that will throw out of bounds maybe do

      for(int i=0;i<synset.length;i++){

      // hehe the example is the important thing anyway i hope ;)

    • Ray

      Ray - 2004-11-23

      Thanx it helped :) .... however just one more thing...
      Consider the example...

      wn amazing -n1 -sysnv gives...
      amaze, astonish, astound => surprise

      Using your code (and the iterating through Word[]) I was only able to get 'amaze', 'astonish', and 'astound' ... however is there a way of getting the word 'surprise'? WordNet says that "Hypernym synsets are preceded by => "... I admit I am a little confused in interpreting WordNet result so in this case my question is should I consider the terms after '=>' given by WordNet. I got confused after I did ...

      wn big -synsa -n2 .. which gave....
      big => important (vs. unimportant), of import

      Using the code you gave me only gives the word 'big' as a result (ie for adj sense 2).

      Once again,
      Thanks for your time

    • leeo

      leeo - 2004-11-23

      not sure on this look at the post more about synsets
      im sure ive seen one bout hypernyms 2

      good luck and let me know how u get on ;)


Log in to post a comment.