小编use*_*286的帖子

nltk“OMW”阿拉伯语词网

我正在使用专门针对阿拉伯语的(OMW)wordnet 来开发python/nltk。所有功能都可以在英语中正常工作,但当我使用“arb”标签时,我似乎无法执行其中任何功能。唯一有效的方法是lemma_names从给定的阿拉伯语同义词集中提取 the 。

\n\n

下面的代码可以与 u'arb' 配合使用:\n输出是阿拉伯语引理列表。

\n\n
for synset in wn.synsets(u'\xd8\xb9\xd8\xa7\xd9\x85',lang=('arb')):\n    for lemma in synset.lemma_names(u'arb'):\n        print lemma\n
Run Code Online (Sandbox Code Playgroud)\n\n

当我尝试使用同义词、定义、示例、上位词执行与上面的代码相同的逻辑时,我收到一条错误消息:

\n\n
TypeError: hyponyms() takes exactly 1 argument (2 given)\n
Run Code Online (Sandbox Code Playgroud)\n\n

(如果我提供'arb'标志)或

\n\n
KeyError: u'arb'\n
Run Code Online (Sandbox Code Playgroud)\n\n

如果我编写以下代码,这是不起作用的代码之一 synset.hyponyms(u'arb')

\n\n
for synset in wn.synsets(u'\xd8\xb9\xd8\xa7\xd9\x85',lang=('arb')):\n    for hypo in synset.hyponyms(): #print the hyponyms in English not Arabic\n        print hypo\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是否意味着我无法使用 wn.all_synsets 和其他内置函数来提取所有阿拉伯语同义词集、上位词等?

\n

python nltk wordnet python-2.7 nltk-book

4
推荐指数
1
解决办法
2103
查看次数

标签 统计

nltk ×1

nltk-book ×1

python ×1

python-2.7 ×1

wordnet ×1