如何检查是否在wordNet中的单词 [英] how to check whether word in wordNet or not

查看:167
本文介绍了如何检查是否在wordNet中的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始学习wordNet,直到知道我找到了特定单词的synonymous 现在我有一个文件,我想使用n-gram例如

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";

使用n-gram后将是

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

,依此类推 然后我想知道tee shirt是否是biword(我可以将其视为搜索索引中的一个单词) 所以我想用wordNet来检查wordNet中的(T恤)

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,则它是一个双字,并且具有同义词,例如球衣,T恤衫,T恤衫

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

if false则不是

Jaws中是否有任何方法检查wordnet中的此单词? 或我应该查看该词是否具有同义词,那么默认情况下是该词(作为我想到的解决方案)

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)

推荐答案

我找到了解决问题的方法,因为没有人回答这个问题 我将为以后的访问者发布具有相同问题的答案 我希望这会有所帮助:)

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; 
    } 

如果WordNet词典中缺少此函数,则返回true

this function return true if it is missing from WordNet dictionary

这篇关于如何检查是否在wordNet中的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆