美文网首页
检测科学摘要中特定的词或词组 (自学43天)

检测科学摘要中特定的词或词组 (自学43天)

作者: 天明豆豆 | 来源:发表于2020-03-24 17:37 被阅读0次

检测科学摘要中特定的词或词组


可以使用上一篇文章所用到的检测科学摘要中的词或词组。一般地,本例还可以适用于进行非常简单的文本挖掘,可类比于 Microsoft Word 的"查找"工具。

import urllib2 
import re 
# word to be searched 

keyword = re.compile('schistosoma')

# list of PMIDs where we want to search the word 

pmids = ['18235848','22607149','22405002','21630672'] 
for pmid in pmids: 
  url = 'http://www.ncbi.nlm.nih.gov/pubmed?term=%s' +%pmid 
  handler=urllib2.urlopen(url)
  html = handler.read() 
  title_regexp = re.compile('<h1>.{5.400}<!h1>') 
  title=title_regexp.search(html) 
  title=title.group() 
  abstract_regexp = re.compile('<h3>Abstract</h3><p>.{20.3000}</p></div>') 
  abstract = abstract_regexp.search(html) 
  abstract = abstract.group() 
  word = keyword.search(abstract,re.IGNORECASE) 

if word: 
# display title and where the keyword was found 
  print (title) 
  print (word.group(),word.start(),word.end())

如果想找出文本单词的所有匹配结果,可以使用 finditer()方法:

import urllib2
import re 
# word to be searched 

word_regexp = re.compile('schistosαna')
# list of PMIDs where we want to search the word 

pmids = ['18235648','22607149','22405002','21630672'] 
for pmid in pmids: 
  url = 'http://www.ncbi.nlm.nih.gov/pubmed?term=%s' +%pmid 
  handler = urllib2.urlopen(url) 
  html = handler.read () 
  title_regexp = re.compile('<h1>.{5,400}</h1>') 
  title = title_regexp.search(html) 
  title = title.group() 
  abstract_regexp = re.compile('<h3>Abstract</h3><P>.{20, 3000}</p></div>') 
  abstract = abstract_regexp.search(html) 
  abstract = abstract.group() 
  words = keyword.finditer(abstract) 
  if words: 
# diaplay title and where the keyword was found 

    print (title)
    for word in words: 
      print (word.group(),word.start(),word.end())

相关文章

  • 检测科学摘要中特定的词或词组 (自学43天)

    检测科学摘要中特定的词或词组 可以使用上一篇文章所用到的检测科学摘要中的词或词组。一般地,本例还可以适用于进行非常...

  • 多模式匹配AC算法Java(kotlin)实现,可建模中文

    目的 在自然语言处理领域,如果我们要在文本中检测特定的词,这就是模式匹配的问题。如果检测多个词,则是多模式匹配。最...

  • 词组

    词组: 由一个或一个以上的词构成的语法单位。 分为: 1. 名词词组(NounPhrase) 2. 动词词组(Ve...

  • Android自定义View 词组高亮控件

    词组高亮的 TextView 控件。额,为什么做这个.... 好吧,之前面试时公司要求的题目 特定词组高亮显示(中...

  • 04|连词不是你的朋友,向“因为、所以、虽然、但是”say go

    连词,是用来连接词与词、词组与词组或句子与句子、表示某种逻辑关系的虚词。连词可以表并列、承接、转折、因果、选择、假...

  • 轧制的大盘卷的线径在线检测

    摘要:对轧制中的大盘卷、高速线材等的在线检测能有效的提升其质量,本文就介绍了轧制中的大盘卷线径如何检测。 关键词:...

  • 学会提问 第三章

    关键词或词组是决定作者的理由是否能支撑其结论的关键所在,找到关键的词语或词组只是第一部,还要理解关键词在文中所要表...

  • 自学“现代汉语语法”笔记—词组

    语素和语素组合成词,词和词组合为词组,最简单的词组是由两个词组成的。 根据词组内部组成成分之间的语法关系,可以把词...

  • 第二节词语规范(三)

    缩略词 缩略词是词语或词组的简缩形式,具有简明便捷的特点。我们在写作中如何规范地使用缩略词,可以从两个方面进行把握...

  • 《短板》44

    中文语法修辞中的词组,是一项有趣味性的课题。 词组是词和词的有机结合的语法单位。 任意两个...

网友评论

      本文标题:检测科学摘要中特定的词或词组 (自学43天)

      本文链接:https://www.haomeiwen.com/subject/iscayhtx.html