我正在尝试使用 spacy NER 从组织地址中提取国家/地区,但是,它使用相同的标签标记国家和城市GPE
。有什么办法可以区分它们吗?
例如:
nlp = en_core_web_sm.load()
doc= nlp('Resilience Engineering Institute, Tempe, AZ, United States; Naval Postgraduate School, Department of Operations Research, Monterey, CA, United States; Arizona State University, School of Sustainable Engineering and the Built Environment, Tempe, AZ, United States; Arizona State University, School for the Future of Innovation in Society, Tempe, AZ, United States')
for ent in doc.ents:
if ent.label_ == 'GPE':
print(ent.text)
Run Code Online (Sandbox Code Playgroud)
回馈
Tempe
AZ
United States
United States
Tempe
AZ
United States
Tempe …
Run Code Online (Sandbox Code Playgroud)