Python 使用stanfordnlp库中的REGEXNER注释作者姓名

Python 使用stanfordnlp库中的REGEXNER注释作者姓名,python,regex,stanford-nlp,ner,Python,Regex,Stanford Nlp,Ner,我的目标是用实体PERSON注释科学文章中的作者姓名。 我对符合这种格式的名称特别感兴趣(authorname等人,date)。 例如,我想用这句话(Minot等人2000)=>将Minot注释为一个人。 我正在使用斯坦福nlp团队官方页面中的代码的改编版本: import stanfordnlp from stanfordnlp.server import CoreNLPClient # example text print('---') print('input text') print(

我的目标是用实体PERSON注释科学文章中的作者姓名。 我对符合这种格式的名称特别感兴趣(authorname等人,date)。 例如,我想用这句话(Minot等人2000)=>将Minot注释为一个人。 我正在使用斯坦福nlp团队官方页面中的代码的改编版本:

import stanfordnlp

from stanfordnlp.server import CoreNLPClient
# example text
print('---')
print('input text')
print('')

text = "In practice, its scope is broad and includes the analysis of a diverse set of samples such as gut microbiome (Qin et al., 2010), (Minot et al., 2011), environmental (Mizuno et al., 2013) or clinical (Willner et al., 2009), (Negredo et al., 2011), (McMullan et al., 2012) samples."

# set up the client
print('---')
print('starting up Java Stanford CoreNLP Server...')
#Properties dictionary
prop={'regexner.mapping': 'rgxrules.txt', 'annotators': 'tokenize,ssplit,pos,lemma,ner,regexner'}
# set up the client


with CoreNLPClient(properties=prop,timeout=100000, memory='16G',be_quiet=False ) as client:
    # submit the request to the server
    ann = client.annotate(text)
    # get the first sentence
    sentence = ann.sentence[0]
运行代码后,我得到以下误报和误报: 内格罗多不是用PERSON来注释的,而是用O和Minot来注释的,因为它是美国的城市之一,但在这句话中,它应该用作者的名字来注释

我试图解决这个问题,是将这一行添加到我传递给corenlpclient的rgxrules.txt文件中。以下是我在此文件中的行:

[[A-Z][a-z]] /et/ /al\./\tPERSON
这并不能解决您可以检查是否运行代码的问题。此外,我不知道如何添加这样一个事实,即我只希望与“[[A-Z][A-Z]]”匹配的单词(位于et al.之前)用PERSON注释,而不是整个句子“Minot et al.”

你知道我怎么解决这个问题吗


提前谢谢。

关于匹配java正则表达式,我很确定您需要类似

[A-Za-z]+等人[.]

但是,我不知道有什么方法可以避免标记
,比如标记先行。如果在regex文件中添加另一行,将
替换为
O
,会发生什么情况?可能需要说明
PERSON
O