Java中的Wordnet相似性:Jaws,JWNL或Java WN ::相似?
-
12-11-2019 - |
题
我需要在基于Java的应用程序中使用WordNet。 我想:
-
搜索套件
-
在synpsets 之间找到相似性/相关性
我的应用程序使用RDF图形,我知道有Wordnet的Sparql端点,但我想最好是数据集的本地副本,因为它不是太大。
我发现了以下jars:
- 常规图书馆 - jaws http:// lyle。 smu.edu/~tspell/jaws/index.html
- 常规图书馆 - jwnl http://sourceforge.net/projects/jwordnet
- 相似性库(perl) - wordnet ::相似性 http:// wn-相似之处..sourceforge.net/
- java版wordnet ::相似 http://www.cogs.susx。 Ac.uk/users/drh21/ (beta)
您将为我的应用推荐什么?
是否可以通过一些绑定使用来自Java应用程序的Perl库?
谢谢! mulone
解决方案
我使用普通Wordnet的jaws,因为它很容易使用。然而,对于相似度量,但是,我使用位于这里。您还需要下载这个文件夹,包含预处理的wordnet和语料库数据,用于工作。假设您将该文件夹放置在项目文件夹中的另一个名为“lib”的文件夹中,可以使用这样的代码:
JWS ws = new JWS("./lib", "3.0");
Resnik res = ws.getResnik();
TreeMap<String, Double> scores1 = res.res(word1, word2, partOfSpeech);
for(Entry<String, Double> e: scores1.entrySet())
System.out.println(e.getKey() + "\t" + e.getValue());
System.out.println("\nhighest score\t=\t" + res.max(word1, word2, partOfSpeech) + "\n\n\n");
.
这将打印以下内容,显示每个可能的待比较词表示的同步组合之间的相似性分数:
hobby#n#1,gardening#n#1 2.6043996588901104
hobby#n#2,gardening#n#1 -0.0
hobby#n#3,gardening#n#1 -0.0
highest score = 2.6043996588901104
.
还有方法允许您指定任何一个/两个单词:res(String word1, int senseNum1, String word2, partOfSpeech)
等的感觉不幸的是,源文档不是javadoc,因此您需要手动检查它。源可以下载 。
可用算法是:
JWSRandom(ws.getDictionary(), true, 16.0);//random number for baseline
Resnik res = ws.getResnik();
LeacockAndChodorowlch = ws.getLeacockAndChodorow();
AdaptedLesk adLesk = ws.getAdaptedLesk();
AdaptedLeskTanimoto alt = ws.getAdaptedLeskTanimoto();
AdaptedLeskTanimotoNoHyponyms altnh = ws.getAdaptedLeskTanimotoNoHyponyms();
HirstAndStOnge hso = ws.getHirstAndStOnge();
JiangAndConrath jcn = ws.getJiangAndConrath();
Lin lin = ws.getLin();
WuAndPalmer wup = ws.getWuAndPalmer();
.
此外,它需要您为mit的 jwi 才有mit的jar文件
其他提示
钳口有功能,以查找类似的Wordforms 以下是详细信息:
public adjectiveyyns [] letsimilar()抛出WordNetException,这里是您可以查看的链接: http://lyle.smu.edu/~tspell/jaws/doc/edu/smu/tspell/wordnet/adjectivesynset.html 此链接它涉及可以使用的详细信息。
我不确定jaws或jwnl是否提供了计算Synpsets之间的相似性的方法,但我已经尝试了搜索统一,并且我发现jaws更易于使用。具体而言,简单:
// Specifying the Database Directory
System.setProperty("wordnet.database.dir", "C:/WordNet/2.1/dict/");
.
对我来说更容易理解jwnl的file_properties.xml要求。