获得JWI和Wordnet的词汇 [英] Getting word stems with JWI and Wordnet

查看:118
本文介绍了获得JWI和Wordnet的词汇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何正确使用词干分析方法在麻省理工学院的JWI(WordNet的Java API)中实现,以获得一个词的词干?我不确定如何初始化一个词干分析器并使用findStems方法。

How do I correctly use the stemmer method implemented in MIT's JWI (Java API for WordNet) in order to get the stem of a word? I'm not sure how to initialize a stemmer and use the findStems method.

推荐答案

您不需要额外的库,但你确实需要一本字典。您可以从普林斯顿下载一个:
https://wordnet.princeton.edu / wordnet / download / current-version /

You don't need an additional library, but you do need a dictionary. You can download one from Princeton: https://wordnet.princeton.edu/wordnet/download/current-version/

我建议只从WordNet 3.1 DATABASE FILES ON部分下载字典
解压缩存档。假设PATH / dict是输出的位置,您可以使用此代码:

I recommend downloading only the dictionary from the section "WordNet 3.1 DATABASE FILES ONLY" Extract the archive. Supposing that PATH/dict is the location of the output you can use this code:

Dictionary dict = new Dictionary(new File("PATH/dict"));
dict.open();
WordnetStemmer stemmer = new WordnetStemmer(dict);

List<String> test = stemmer.findStems("feet", POS.NOUN);
for (int i = 0; i < test.size(); i++) {
    System.out.println(test.get(i));
}

此示例的输出为foot。

The output for this example is "foot".

这篇关于获得JWI和Wordnet的词汇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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