1 Star 0 Fork 0

伊拉克肥灵/NewN

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
3.py 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
伊拉克肥灵 提交于 2020-07-06 20:26 . 2.5
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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/estaryjl/NewN.git
git@gitee.com:estaryjl/NewN.git
estaryjl
NewN
NewN
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385