gensim.summarization库的函数 gensim.summarization.summarize(text, ratio=0.2, word_count=None, split=False) Parameters(参数): text : str Given text. ratio : float, optional Number between 0 and 1 that determines the proportion of the number of sentences of the original text to be chosen for the summary. word_count : int or None, optional Determines how many words will the output contain. If both parameters are provided, the ratio will be ignored. split : bool, optional If True, list of sentences will be returned. Otherwise joined strings will bwe returned.

代码

from gensim.summarization import summarize # 基于文本排序的摘要算法

from bs4 import BeautifulSoup # 用于解析HTML文档的BeautifulSoup库

import requests # 用于下载HTTP资源的库

urls = { # 题目:网站 字典

'Deconstructing Voice-over-IP':

'http://scigen.csail.mit.edu/scicache/269/scimakelatex.25977.A.+G.+Hassan.html',

'Exploration of the Location-Identity Split':

'http://scigen.csail.mit.edu/scicache/270/scimakelatex.26087.Ali+Veli.Veli+Ali.Vel+Al.html',

}

# 摘要(真实的):

# 1.The implications of ambimorphic archetypes have been far-reaching and pervasive. After years of natural research into consistent hashing, we argue the simulation of public-private key pairs, which embodies the confirmed principles of theory. Such a hypothesis might seem perverse but is derived from known results. Our focus in this paper is not on whether the well-known knowledge-based algorithm for the emulation of checksums by Herbert Simon runs in Θ( n ) time, but rather on exploring a semantic tool for harnessing telephony (Swale).

# 2.Superblocks must work. Given the current status of homogeneous configurations, security experts particularly desire the simulation of 802.11b. we consider how the Internet can be applied to the refinement of Scheme.

for key in urls.keys():

url = urls[key]

r = requests.get(url)

soup = BeautifulSoup(r.text,'html.parser')

data = soup.get_text() # HTML去标签后的文本

pos1 = data.find('1 Introduction') + len('1 Introduction')

pos2 = data.find('Related Work')

text = data[pos1:pos2].strip() # 提取pos1与pos2之间的引言部分

print('PAPER URL: {}'.format(url))

print('TITLE: {}'.format(key))

print('GENERATED SUMMARY: {}'.format(summarize(text)))

print()

输出:

PAPER URL: http://scigen.csail.mit.edu/scicache/269/scimakelatex.25977.A.+G.+Hassan.html

TITLE: Deconstructing Voice-over-IP

GENERATED SUMMARY: 。。。。。。

PAPER URL: http://scigen.csail.mit.edu/scicache/270/scimakelatex.26087.Ali+Veli.Veli+Ali.Vel+Al.html

TITLE: Exploration of the Location-Identity Split

GENERATED SUMMARY: 。。。。。。

python nlp文本摘要_NLP(十一) 提取文本摘要相关推荐

  1. python从文件中提取特定文本_python利用正则表达式提取文本中特定内容

    正则表达式是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配. Python 自1.5版本起增加了re 模块,它提供 Perl 风格的正则表达式模式. re 模块使 Python ...

  2. delphi 停电文本数据丢失_NLP中的文本分析和特征工程

    语言检测,文本清理,长度测量,情绪分析,命名实体识别,n字频率,词向量,主题建模 前言 在本文中,我将使用NLP和Python解释如何分析文本数据并为机器学习模型提取特征. NLP(自然语言处理)是人 ...

  3. python论文摘要_Python实现提取文章摘要的方法

    本文实例讲述了Python实现提取文章摘要的方法.分享给大家供大家参考.具体如下: 一.概述 在博客系统的文章列表中,为了更有效地呈现文章内容,从而让读者更有针对性地选择阅读,通常会同时提供文章的标题 ...

  4. python中文文本分词_SnowNLP:?中文分词?词性标准?提取文本摘要,?提取文本关键词,?转换成拼音?繁体转简体的 处理中文文本的Python3 类库...

    SnowNLP是一个python写的类库,可以方便的处理中文文本内容,是受到了TextBlob的启发而写的,由于现在大部分的自然语言处理库基本都是针对英文的,于是写了一个方便处理中文的类库,并且和Te ...

  5. python自动翻译pdf_python实现从pdf文件中提取文本,并自动翻译的方法

    针对Python 3.5.2 测试 首先安装两个包: $ pip install googletrans $ pip install pdfminer3k googletrans会提供一个命令tran ...

  6. python用来自动修改pdf_python实现从pdf文件中提取文本,并自动翻译的方法

    针对Python 3.5.2 测试 首先安装两个包: $ pip install googletrans $ pip install pdfminer3k googletrans会提供一个命令tran ...

  7. nlp中文文本摘要提取,快速提取文本主要意思

    文本摘要提取 之前写过一版 文本摘要提取,但那版并不完美.有所缺陷(但也获得几十次收藏). 中文文本摘要提取 (文本摘要提取 有代码)基于python 今天写改进版的文本摘要提取. 文本摘要旨在将文本 ...

  8. python nlp文本摘要实现_用TextRank算法实现自动文本摘要

    [51CTO.com快译]1. 引言 文本摘要是自然语言处理(NLP)领域中的应用之一,它必将对我们的生活产生巨大影响.随着数字媒体和出 版业的不断发展,谁还有时间浏览整篇文章/文档/书籍来决定它们是 ...

  9. NLP:基于nltk和jieba库对文本实现提取文本摘要(两种方法实现:top_n_summary和mean_scored_summary)

    NLP:基于nltk和jieba库对文本实现提取文本摘要(两种方法实现:top_n_summary和mean_scored_summary) 目录 输出结果 设计思路 核心代码 输出结果 1.测试文本 ...

  10. NLP:基于snownlp库对文本实现提取文本关键词和文本摘要

    NLP:基于snownlp库对文本实现提取文本关键词和文本摘要 目录 输出结果 1.测试文本 设计思路 核心代码 输出结果 1.测试文本 今天一大早,两位男子在故宫抽烟对镜头炫耀的视频在网络上传播,引 ...

最新文章

  1. 【原创】如何分析一个网站使用的服务器类型
  2. eclipse 环境下 FreeMarker 编辑器插件
  3. Kvm虚拟机克隆以及添加磁盘
  4. 需求规格说明书(SRS)特点
  5. 【计算机网络】HTTP 与 HTTPS ( HTTPS 简介 | HTTP 通信过程 )
  6. Java开发主流框架是什么?
  7. 【剑指offer】面试题42:连续子数组的最大和(java)
  8. html个人主页_前端性能优化实践 之 百度App个人主页优化
  9. Buffer、ArrayBuffer、DataView互转(node.js)
  10. Noip2008提高组初赛 C
  11. Vb如何设计编程计算机,vb程序设计论文
  12. vb.net 画多个矩形_电气原理图和接线图识图方法,电气接线图怎么画?
  13. 如何搭建靠谱的测试环境
  14. django注册登录
  15. SecureCRT绿色破解版(解压即可,无注册机)
  16. 原型工具XSTAR与AXURE对比
  17. scratch编程小游戏——黄金矿工
  18. Android 手写和笔锋研究资料
  19. Flume下读取kafka数据后再打把数据输出到kafka,利用拦截器解决topic覆盖问题
  20. java 内存 监控_Java内存监视

热门文章

  1. 字节跳动---雀魂启动
  2. diy计算机工作站,程序猿 篇一:迟到的 618 攒机实录:自建巨硬工作站
  3. 400错误,The server cannot or will not process the request due to something that is perceived to be a c
  4. 专题分纲目录 思维导图
  5. 光大祖业 奉子成婚——SAS与SATA-Ⅱ专题
  6. 百度关闭快照删除更新入口
  7. echarts-wordcloud 热词云使用
  8. 通过函数seaborn.cubehelix_palette生成顺序调色板
  9. 算法-经典趣题-三色旗
  10. 哈夫曼树及哈夫曼编码(10分)