使用JWNL获取与WordNet中的动词相关的所有名词 [英] Getting all nouns related to a verb in WordNet using JWNL

查看:125
本文介绍了使用JWNL获取与WordNet中的动词相关的所有名词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JWNL(1.4.1 rc2).给定一个动词,我需要找到相关"名词.例如,给定动词:bear我想要名词birth.

I am using JWNL (1.4.1 rc2). Given a verb, I need to find "related" nouns. For example, given the verb: bear I want the noun birth.

我可以通过WordNet在线界面看到它:

I can see this through the WordNet online interface: http://wordnetweb.princeton.edu/perl/webwn?o2=&o0=1&o8=1&o1=1&o7=&o5=&o9=&o6=&o3=&o4=&s=bear&i=8&h=000100000000000000000#c. How would this be done in JWNL.

推荐答案

您可以对词的每种含义使用Synset,然后按如下所示在每个Synset中打印出该词:

You can use the Synset for each sense of the word, then print out the word in each Synset, as follows:


IndexWord indexWord = proc.lookupBaseForm(POS.VERB,"bear");
int senseNum = 0;
for(Synset synset: indexWord.getSenses()){
    senseNum++;
    System.out.println("For sense: " + senseNum + " (" + synset.getGloss()+")");
    Word[] words = synset.getWords();
    for(Word word: words){
        System.out.println("\t"+word.getLemma()+"("+word.getPOS()+")");
    }
}

这将为您带来帮助:


For sense: 1 (have; "bear a resemblance"; "bear a signature")
    bear([POS: verb])
For sense: 2 (cause to be born; "My wife had twins yesterday!")
    give_birth([POS: verb])
    deliver([POS: verb])
    bear([POS: verb])
    birth([POS: verb])
    have([POS: verb])
For sense: 3 (put up with something or somebody unpleasant; "I cannot bear his constant criticism"; "The new secretary had to endure a lot of unprofessional remarks"; "he learned to tolerate the heat"; "She stuck out two years in a miserable marriage")
    digest([POS: verb])
    endure([POS: verb])
    stick_out([POS: verb])
    stomach([POS: verb])
    bear([POS: verb])
    stand([POS: verb])
    tolerate([POS: verb])
    support([POS: verb])
    brook([POS: verb])
    abide([POS: verb])
    suffer([POS: verb])
    put_up([POS: verb])
For sense: 4 (move while holding up or supporting; "Bear gifts"; "bear a heavy load"; "bear news"; "bearing orders")
    bear([POS: verb])
For sense: 5 (bring forth, "The apple tree bore delicious apples this year"; "The unidentified plant bore gorgeous flowers")
    bear([POS: verb])
    turn_out([POS: verb])
For sense: 6 (take on as one's own the expenses or debts of another person; "I'll accept the charges"; "She agreed to bear the responsibility")
    bear([POS: verb])
    take_over([POS: verb])
    accept([POS: verb])
    assume([POS: verb])
For sense: 7 (contain or hold; have within; "The jar carries wine"; "The canteen holds fresh water"; "This can contains water")
    hold([POS: verb])
    bear([POS: verb])
    carry([POS: verb])
    contain([POS: verb])
For sense: 8 (bring in; "interest-bearing accounts"; "How much does this savings certificate pay annually?")
    yield([POS: verb])
    pay([POS: verb])
    bear([POS: verb])
For sense: 9 (have on one's person; "He wore a red ribbon"; "bear a scar")
    wear([POS: verb])
    bear([POS: verb])
For sense: 10 (behave in a certain manner; "She carried herself well"; "he bore himself with dignity"; "They conducted themselves well during these difficult times")
    behave([POS: verb])
    acquit([POS: verb])
    bear([POS: verb])
    deport([POS: verb])
    conduct([POS: verb])
    comport([POS: verb])
    carry([POS: verb])
For sense: 11 (have rightfully; of rights, titles, and offices; "She bears the title of Duchess"; "He held the governorship for almost a decade")
    bear([POS: verb])
    hold([POS: verb])
For sense: 12 (support or hold in a certain manner; "She holds her head high"; "He carried himself upright")
    hold([POS: verb])
    carry([POS: verb])
    bear([POS: verb])
For sense: 13 (be pregnant with; "She is bearing his child"; "The are expecting another child in January"; "I am carrying his child")
    have_a_bun_in_the_oven([POS: verb])
    bear([POS: verb])
    carry([POS: verb])
    gestate([POS: verb])
    expect([POS: verb])

但这就是所有动词,因为我们正在查找动词.如果要获取名词(如Web版本所示),则应执行一些进一步的步骤.

But that's all verb, since we are looking up verbs. If you want to get noun (as seen in the Web version), you should do some further steps.

被称为"morphosemantic"的相关单词,在此文件中定义,如 Wordnet网站所述.您可以使用该文件上可用的映射来创建自己的代码以提取词法相关的单词.

It's called "morphosemantic"ally related words, which is defined in this file, as stated in Wordnet website. You can create your own code to extract morphosemantically related words by using the mapping available on that file.

由于这是标准WordNet发行版之外的另一个文件,很遗憾,我相信这不是在JWNL中实现的,因此,如果您可以仅创建一个简单的代码来获取映射,那可能是最好的选择.首先,您可以使用任何电子表格程序(例如Excel)将xls文件转换为CSV文件.然后,您需要获取该感觉的感觉关键.不幸的是,JWNL(1.4.1 rc2)没有简单的方法来获取检测键.但是,它包含在JWNL(1.4 rc3)中,它是类Synset中的方法getSenseKey(lemma).因此,假设您升级到JWNL 1.4_rc3,则可以执行以下操作:

Since this is an additional file beyond standard WordNet distribution, regretfully I believe this is not implemented in JWNL, so probably it's best if you can just create a simple code to get the mapping. First, you can convert the xls file into CSV file using any spreadsheet program such as Excel. Then you'll need to get the sense key of that sense. Unfortunately, JWNL (1.4.1 rc2) has no simple method to get the sense key. However, it's included in JWNL (1.4 rc3), which is the method getSenseKey(lemma) in the class Synset. So, assuming you upgrade to JWNL 1.4_rc3, you can do:

HashMap<String,ArrayList<String>> relatedWords = loadMorphosemanticFile();
...
relatedWords.get(word.getSynset().getSenseKey(word.getLemma()))

,当单词为birth(在bear的含义2中)时,它将返回一个由birth%1:28:00::birth%1:22:00::birth%1:11:00::组成的Arraylist(感知键bear%2:29:01 :: ,导致出生;我的妻子昨天有双胞胎!"),它具有关键的出生日期%2:29:00 ::,如下面使用JWNL 1.4 rc3的输出所示:

which will return an Arraylist consisting of: birth%1:28:00::, birth%1:22:00::, and birth%1:11:00:: when the word is birth in the sense 2 of bear (sense key bear%2:29:01::, cause to be born; "My wife had twins yesterday!"), which has the sense key birth%2:29:00::, as can be seen in the output using JWNL 1.4 rc3 below:


For sense: bear%2:29:01:: (cause to be born; "My wife had twins yesterday!")
    give_birth (give_birth%2:29:00::)
    deliver (deliver%2:29:01::)
    bear (bear%2:29:01::)
    birth (birth%2:29:00::)
    have (have%2:29:00::)

我从 查看全文

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