【问题标题】:Is it possible to get a list of words given the Lemma in Spacy?是否有可能在 Spacy 中获得给定引理的单词列表?
【发布时间】:2020-09-08 22:49:01
【问题描述】:

我正在尝试修复法语文本中的语法性别,并想知道是否有办法从某个引理中获取所有单词的列表以及是否可以在此类列表中进行查找?

【问题讨论】:

  • 是的,谢尔盖,您的解决方案非常适合我打算完成的工作。非常感谢:)。

标签: python nlp spacy lemmatization


【解决方案1】:

试试:

import spacy
lemma_lookup = spacy.lang.en.LOOKUP

reverse_lemma_lookup = {}

for word,lemma in lemma_lookup.items():
    if not reverse_lemma_lookup.get(lemma):
        reverse_lemma_lookup[lemma] = [word]
    elif word not in reverse_lemma_lookup[lemma]:
        reverse_lemma_lookup[lemma].append(word)

reverse_lemma_lookup["be"]
["'m", 'am', 'are', 'arst', 'been', 'being', 'is', 'm', 'was', 'wass', 'were']

spacy.lang.en.LOOKUP 更改为spacy.lang.fr.LOOKUP 我猜是法语

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-08
    • 1970-01-01
    • 1970-01-01
    • 2021-08-21
    • 1970-01-01
    • 2020-01-16
    • 2013-04-24
    相关资源
    最近更新 更多