代码拉取完成,页面将自动刷新
import spacy
from spacy import displacy
nlp=spacy.load('en_core_web_sm')
def solve():
doc=nlp("""Infections with Legionella bacteria can subclinical cause a potentially lethal form of pneumonia known as legionnaires' disease. In 1999 a major outbreak, causing 31 deaths, occurred among visitors and exhibitors of a consumer fair in The Netherlands. The epidemiology of subclinical infections is largely unknown, as there epidemiology of is no reliable method to diagnose such infections. To explore the incidence of subclinical infections, IgG and IgM antibody levels epidemiology of among exhibitors were compared to those among a representative sample of the Dutch population. As exhibitors were assumed to comprise both infected and uninfected individuals, their antibody levels were modelled as a mixture distribution. As infected individuals are expected to cluster around a point source, the spatial aspect of the spread of infections was taken into account. To estimate the distribution of antibody levels among infected individuals and to impute infection status among exhibitors, data augmentation was used. Subclinical infection appeared to be very common and its frequency declined with the distance from the putative source of the outbreak. Copyright (C) 2003 John Wiley Sons, Ltd.""")
list=[]
list2=[]
word=nlp('epidemiology of subclinical')
for onesentence in doc.sents:
if str(word) in str(onesentence):
for wrodinsen in onesentence:
if str(wrodinsen) in str(word):
list.append(wrodinsen.text + "/B")
else:
list.append(wrodinsen.text + "/I")
# list2.append(ans.text+"/B" if str(ans) in str(word) else ans.text+"/I")
list.extend(list2[:-1]+['./O'])
list2.clear()
else:
for res in onesentence:
list.append(res.text+"/O")
# print(doc)t
file = open("newfile.txt","a",encoding="utf-8")
print(list)
for l in list:
print(l,file=file)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。