CoreNLP能否确定一个普通名词(与专有名词或专有名称相对)是指一个开箱即用的人?或者,如果我需要为此任务训练模型,我该如何解决?
首先,我不是在寻找共识解决方案,而是寻找它的构建块。根据定义,共同依赖取决于上下文,而我试图评估孤立的单词是否是“人”或“人”的子集。例如:
is_human('effort') # False
is_human('dog') # False
is_human('engineer') # True
我天真地尝试使用Gensim和spaCy的预训练单词向量未能将“工程师”排在其他两个单词之上。
import gensim.downloader as api
word_vectors = api.load("glove-wiki-gigaword-100")
for word in ('effort', 'dog', 'engineer'):
print(word, word_vectors.similarity(word, 'person'))
# effort 0.42303842
# dog 0.46886832
# engineer 0.32456854
我发现以下来自CoreNLP的名单很有希望。
dcoref.demonym // The path for a file that includes a list of demonyms
dcoref.animate // The list of animate/inanimate mentions (Ji and Lin, 2009)
dcoref.inanimate
dcoref.male // The list of male/neutral/female mentions (Bergsma and Lin, 2006)
dcoref.neutral // Neutral means a mention that is usually referred by 'it'
dcoref.female
dcoref.plural // The list of plural/singular mentions (Bergsma and Lin, 2006)
dcoref.singular
这些对我的任务有用吗?如果是这样,我将如何从Python wrapper访问它们?谢谢。
我建议改为尝试WordNet,看看:
person.n.01
的下位词。你必须扩展它以涵盖多种感官,但要点是:
from nltk.corpus import wordnet as wn
# True
wn.synset('person.n.01') in wn.synset('engineer.n.01').lowest_common_hypernyms(wn.synset('person.n.01'))
# False
wn.synset('person.n.01') in wn.synset('dog.n.01').lowest_common_hypernyms(wn.synset('person.n.01'))
请参阅lowest_common_hypernym
:http://www.nltk.org/howto/wordnet_lch.html的NLTK文档