javajaws-wordnet

how to check whether word in wordNet or not


I start to learn about wordNet and till know I found the synonymous for a specific word now I have a file and I want to tokenize this text using n-gram for example

String s="I like to wear tee shirt";

after using n-gram it will be

I
like
to 
wear 
tee 
shirt
.
.
.
wear tee
tee shirt

and so on and then I want to know if tee shirt is a biword (I can consider it as one word in the search index) so I thought to use wordNet to check whether (tee shirt) in wordNet or not

if True then it is a biword and have a synonymous for example jersey, T-shirt, tee shirt

if false then it is Not

is there any method in Jaws check if this word in wordnet or not?? or I should see if the word has a synonymous then it's by default in it (as a solution I thought of)


Solution

  • I found a solution for my problem since no one answer the question I will post what the answer for future visitor that will have the same problem I hope that will be useful :)

    public static boolean is_Missing_WordNet(String r,String posTag){
       // System.out.println("inside is_missing_Wordnet "+r);
              boolean flag=true;
                  configureJWordNet();
                  Dictionary dictionary = Dictionary.getInstance();
                  IndexWord word;
            try {
                if(posTag.equals("VBG"))//Verb
                     { word = dictionary.lookupIndexWord(POS.VERB, r);}
                else {word = dictionary.lookupIndexWord(POS.NOUN, r);}
    
                Synset[] senses = word.getSenses();
    
                    if(senses!=null && senses.length>0){
                     if(senses[0].toString().toLowerCase().contains(r)|| senses[0].toString().contains(r.replace(" ","_")))
                     { System.out.println("sense;;;; "+senses[0].toString());flag=false;}
                      }                                       
                    else{System.out.println("wordnet has no sense of "+r );return true; }
    
    
                    }
            catch(NullPointerException ex){return true;}
             catch (JWNLException ex) {return true;
                        }
            return flag; 
        } 
    

    this function return true if it is missing from WordNet dictionary