【问题标题】:all possible wordform completions of a (biomedical) word's stem(生物医学)词干的所有可能的词形补全
【发布时间】:2015-07-23 19:30:27
【问题描述】:

我熟悉 R 中的 tm 包中的词干提取和完成。

我试图想出一种快速而肮脏的方法来查找给定单词的所有变体(在某些语料库中)。例如,如果我的输入是,我想获得“leukocytes”和“leuckocytic” “白细胞”。

如果我现在必须这样做,我可能会选择以下内容:

library(tm)
library(RWeka)
dictionary <- unique(unlist(lapply(crude, words)))
grep(pattern = LovinsStemmer("company"), 
    ignore.case = T, x = dictionary, value = T)

我使用 Lovins 是因为 Snowball 的 Porter 似乎不够激进。

我对其他词干分析器、脚本语言(Python?)或完全不同的方法的建议持开放态度。

【问题讨论】:

  • 您能举一个例子,说明您提出的解决方案不能满足您的要求吗?波特词干分析器不够激进是什么意思?

标签: python r nlp bioinformatics text-mining


【解决方案1】:

此解决方案需要预处理您的语料库。但是一旦完成,它是一个非常快速的字典查找。

from collections import defaultdict
from stemming.porter2 import stem

with open('/usr/share/dict/words') as f:
    words = f.read().splitlines()

stems = defaultdict(list)

for word in words:
    word_stem = stem(word)
    stems[word_stem].append(word)

if __name__ == '__main__':
    word = 'leukocyte'
    word_stem = stem(word)
    print(stems[word_stem])

对于/usr/share/dict/words 语料库,这会产生结果

['leukocyte', "leukocyte's", 'leukocytes']

它使用stemming模块,可以安装

pip install stemming

【讨论】:

  • 回到这个话题。在 Ubuntu 16.04.2、Python 2.7.12 下运行,这不会为“白细胞”返回任何内容。也许我们的单词文件不同?!用 'jealous' 得到 ['jealous', 'jealously', 'jealousness']。 'muscle' 是 ['muscle', 'muscled', 'musculing'],但不是 'muscular'。所以我想这是一个部分解决方案。也许我对反向词干的期望过高,尤其是生物医学术语。我可以从uberon.github.io 获得复数和形容词形式
猜你喜欢
  • 2021-09-16
  • 2011-07-27
  • 2014-11-02
  • 1970-01-01
  • 2019-08-16
  • 1970-01-01
  • 2017-06-21
  • 2016-06-03
  • 1970-01-01
相关资源
最近更新 更多