简体   繁体   English

CoreNLP:可以判断名词是否指代人吗?

[英]CoreNLP: Can it tell whether a noun refers to a person?

Can CoreNLP determine whether a common noun (as opposed to a proper noun or proper name) refers to a person out-of-the-box? CoreNLP可以确定通用名词(与专有名词或专有名称相对)是否是指开箱即用的人? Or if I need to train a model for this task, how do I go about that? 或者,如果我需要为此任务训练一个模型,该如何处理?

First, I am not looking for coreference resolution, but rather a building block for it. 首先,我不是在寻求共指解决方案,而是为此而构建的模块。 Coreference by definition depends on the context, whereas I am trying to evaluate whether a word in isolation is a subset of "person" or "human". 根据定义,共指取决于上下文,而我试图评估孤立的单词是“人”还是“人”的子集。 For example: 例如:

is_human('effort') # False
is_human('dog') # False
is_human('engineer') # True

My naive attempt to use Gensim's and spaCy's pre-trained word vectors failed to rank "engineer" above the other two words. 我天真的尝试使用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

I found the following lists from CoreNLP promising. 我发现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

Would these work for my task? 这些可以满足我的任务吗? And if so, how would I access them from the Python wrapper ? 如果是这样,我将如何从Python包装器访问它们? Thank you. 谢谢。

I would suggest trying WordNet instead and see: 我建议改用WordNet,然后查看:

  1. if enough of your terms are covered by WordNet and 如果WordNet涵盖了您的足够条款,并且
  2. if the terms you want are hyponyms of person.n.01 . 如果您要使用的术语是person.n.01词。

You'd have to expand this a bit to cover multiple senses, but the gist would be: 您必须将其扩展一些以涵盖多种感官,但要旨是:

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'))

See the NLTK docs for lowest_common_hypernym : http://www.nltk.org/howto/wordnet_lch.html 请参阅NLTK文档以获取lowest_common_hypernymhttp : lowest_common_hypernym

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM