使用 NLP 进行文本摘要
一、说明
二、为什么要自动文本摘要?
- 摘要减少了阅读时间。
- 研究文档时,摘要使选择过程变得更加容易。
- 自动摘要提高了索引的有效性。
- 自动摘要算法比人工摘要的偏差更小。
- 个性化摘要在问答系统中非常有用,因为它们提供个性化信息。
- 使用自动或半自动摘要系统使商业摘要服务能够增加其能够处理的文本文档的数量。
三、文本总结的依据
在下图,至少出现了三个环节,1)文档归类 2)文档目的归类 3)主题信息抽取。

3.1 基于输入类型:
- Single Document ,输入长度较短。许多早期的摘要系统处理单文档摘要。
- 多文档,输入可以任意长。
3.2 根据目的的归类
- 通用,模型不对要总结的文本的领域或内容做出任何假设,并将所有输入视为同类。已完成的大部分工作都是围绕通用摘要展开的。
- 特定领域,模型使用特定领域的知识来形成更准确的摘要。例如,总结特定领域的研究论文、生物医学文献等。
- 基于查询,其中摘要仅包含回答有关输入文本的自然语言问题的信息。
3.3 根据输出类型:
- 提取,从输入文本中选择重要的句子以形成摘要。当今大多数总结方法本质上都是提取性的。
- 抽象,模型形成自己的短语和句子,以提供更连贯的摘要,就像人类会生成的一样。这种方法肯定更有吸引力,但比提取摘要困难得多。
四、如何进行文本摘要
- 文字清理
- 句子标记化
- 单词标记化
- 词频表
- 总结
4.1 文字清理:
# !pip instlla -U spacy
# !python -m spacy download en_core_web_sm
import spacy
from spacy.lang.en.stop_words import STOP_WORDS
from string import punctuation
stopwords = list(STOP_WORDS)
nlp = spacy.load(‘en_core_web_sm’)
doc = nlp(text)
4.2 单词标记化:
tokens = [token.text for token in doc]
print(tokens)
punctuation = punctuation + ‘\n’
punctuation
word_frequencies = {}
for word in doc:
if word.text.lower() not in stopwords:
if word.text.lower() not in punctuation:
if word.text not in word_frequencies.keys():
word_frequencies[word.text] = 1
else:
word_frequencies[word.text] += 1
print(word_frequencies)
4.3 句子标记化:
max_frequency = max(word_frequencies.values())
max_frequency
for word in word_frequencies.keys():
word_frequencies[word] = word_frequencies[word]/max_frequency
print(word_frequencies)
sentence_tokens = [sent for sent in doc.sents]
print(sentence_tokens)
4.4 建立词频表:
sentence_scores = {}
for sent in sentence_tokens:
for word in sent:
if word.text.lower() in word_frequencies.keys():
if sent not in sentence_scores.keys():
sentence_scores[sent] = word_frequencies[word.text.lower()]
else:
sentence_scores[sent] += word_frequencies[word.text.lower()]
sentence_scores
4.5 主题信息总结:
from heapq import nlargest
select_length = int(len(sentence_tokens)*0.3)
select_length
summary = nlargest(select_length, sentence_scores, key = sentence_scores.get)
summary
final_summary = [word.text for word in summary]
summary = ‘ ‘.join(final_summary)
输入原始文档:
text = “””
Maria Sharapova has basically no friends as tennis players on the WTA Tour. The Russian player has no problems in openly speaking about it and in a recent interview she said: ‘I don’t really hide any feelings too much.
I think everyone knows this is my job here. When I’m on the courts or when I’m on the court playing, I’m a competitor and I want to beat every single person whether they’re in the locker room or across the net.
So I’m not the one to strike up a conversation about the weather and know that in the next few minutes I have to go and try to win a tennis match.
I’m a pretty competitive girl. I say my hellos, but I’m not sending any players flowers as well. Uhm, I’m not really friendly or close to many players.
I have not a lot of friends away from the courts.’ When she said she is not really close to a lot of players, is that something strategic that she is doing? Is it different on the men’s tour than the women’s tour? ‘No, not at all.
I think just because you’re in the same sport doesn’t mean that you have to be friends with everyone just because you’re categorized, you’re a tennis player, so you’re going to get along with tennis players.
I think every person has different interests. I have friends that have completely different jobs and interests, and I’ve met them in very different parts of my life.
I think everyone just thinks because we’re tennis players we should be the greatest of friends. But ultimately tennis is just a very small part of what we do.
There are so many other things that we’re interested in, that we do.’
“””
4.6 输出(最终摘要):摘要
I think just because you’re in the same sport doesn’t mean that you have to be friends with everyone just because you’re categorized, you’re a tennis player, so you’re going to get along with tennis players. Maria Sharapova has basically no friends as tennis players on the WTA Tour. I have friends that have completely different jobs and interests, and I’ve met them in very different parts of my life. I think everyone just thinks because we’re tennis players So I’m not the one to strike up a conversation about the weather and know that in the next few minutes I have to go and try to win a tennis match. When she said she is not really close to a lot of players, is that something strategic that she is doing?
有关完整代码,请查看我的存储库:
五、结语
本文至少精简地告诉大家,文章自动摘要需要哪些关键环节。
创建数据集可能是一项繁重的工作,并且经常是学习数据科学中被忽视的部分,实际工作要给以重视。不过,这是另一篇博客文章。阿努普·辛格
相关文章:
使用 NLP 进行文本摘要
一、说明 文本摘要是为较长的文本文档生成简短、流畅且最重要的是准确摘要的过程。自动文本摘要背后的主要思想是能够从整个集合中找到最重要信息的一小部分,并以人类可读的格式呈现。随着在线文本数据的增长,自动文本摘要方法可能会非常有用,…...
vue3挂载全局方法和组件
话不多说直接上代码 main.js import { createApp } from vue import App from ./App.vueconst app createApp(App)// 注册全局方法和组件 function myMethod(){console.log(Hello, world!); } app.provide("myMethod", myMethod) // provide注册全局方法 inject获取…...
mybatisplus学习笔记
1.踩过的坑 1.MybatisPlus 要与其代码生成器的版本一致; 2.要使用新版代码(3.5.1及以上)生成器则要使用springboot3,如果用springboot2使用新版代码生成器会导致builder.parent(“com.sdfsf”) // 设置父包名》重复!&…...
go mod 添加私有库GOPRIVATE
私有地址 形式仓库域名/组织名形式仓库域名形式*仓库域名 示例私有地址: gitee.com/takujo_admin 或者igitlab.com 多个私有地址,分割,示例: gitee.com,igitlab.com 修改env go env -w GOPRIVATE"私有地址" go env -w …...
07-HDFS入门及shell命令
1 文件系统 是一种存储和组织数据的方法,它使得文件访问和查询变得容易使得文件和树形目录的抽象逻辑概念代替了磁盘等物理设备使用数据块的概念,用户使用文件系统来保存数据不必关心数据底层存在硬盘哪里,只需记住这个文件的所属目录和文件…...
TiDB在科捷物流神州金库核心系统的应用与实践
业务背景 北京科捷物流有限公司于2003年在北京正式成立,是ISO质量管理体系认证企业、国家AAAAA级物流企业、海关AEO高级认证企业,注册资金1亿元,是中国领先的大数据科技公司——神州控股的全资子公司。科捷物流融合B2B和B2C的客户需求&#…...
React 18 更新 state 中的数组
参考文章 更新 state 中的数组 数组是另外一种可以存储在 state 中的 JavaScript 对象,它虽然是可变的,但是却应该被视为不可变。同对象一样,当想要更新存储于 state 中的数组时,需要创建一个新的数组(或者创建一份已…...
【css】css中使用变量var
CSS 变量可以有全局或局部作用域。 全局变量可以在整个文档中进行访问/使用,而局部变量只能在声明它的选择器内部使用。 如需创建具有全局作用域的变量,请在 :root 选择器中声明它。 :root 选择器匹配文档的根元素。 如需创建具有局部作用域的变量&am…...
判断自己网络所在的NAT类型
文章目录 各NAT类型介绍软件准备流程 各NAT类型介绍 NAT0: OpenInternet,没有经过NAT地址转换,公网IP NAT1: Full Cone NAT,动态家宽可以达到最优的状态,外网设备可以主动发信息给NAT1网络内的设备。 NAT2: Address-Restricted C…...
ClickHouse(十九):Clickhouse SQL DDL操作-1
进入正文前,感谢宝子们订阅专题、点赞、评论、收藏!关注IT贫道,获取高质量博客内容! 🏡个人主页:含各种IT体系技术,IT贫道_Apache Doris,大数据OLAP体系技术栈,Kerberos安全认证-CSDN博客 &…...
小程序保留2位小数据,不四舍五入
方法1: parseInt toFixed /* * 保留2位小数,不四舍五入 * 5.992550 >5.99 , 2 > 2.00 * */ const toFixed2Decimal (value) > {return (parseInt(value*100)/100).toFixed(2) } console.log(587.67*100) console.log(toFixed2Decimal(587.67…...
【linux-nginx】nginx限流以及控制访问方法
一、限流 可以使用一些模块和指令来实现限流。以下是一些常用的方法: 使用 ngx_http_limit_req_module 模块:该模块可以限制每个客户端的请求速率。你可以在 Nginx 的配置文件中启用该模块,并使用 limit_req_zone 指令来定义限流规则。例如…...
菜单和内容滚动的联动原理及代码
之前写代码有个需求:左侧是一个菜单,右边是内容,点击左侧菜单右边内容滚动到对应位置,右边内容滚动到某位置时,左侧菜单也会选中对应的菜单项。UI如下:这是大多网站的移动端都会有的需求。 解决方案一&…...
Python爬虫:单线程、多线程、多进程
前言 在使用爬虫爬取数据的时候,当需要爬取的数据量比较大,且急需很快获取到数据的时候,可以考虑将单线程的爬虫写成多线程的爬虫。下面来学习一些它的基础知识和代码编写方法。 一、进程和线程 进程可以理解为是正在运行的程序的实例。进…...
超强的Everything,吊打系统自带文件搜索功能!
目录 一、软件简介 二、软件下载 三、软件说明 一、软件简介 Everything是一款由David OReilly开发的电脑搜索软件,它可以帮助用户快速找到电脑上的文件和文件夹。与其他搜索工具不同的是,Everything使用了一种非常快速和高效的搜索算法,…...
flink配置参数
flink-conf.yaml 基础配置 # jobManager 的IP地址jobmanager.rpc.address: localhost# JobManager 的端口号jobmanager.rpc.port: 6123# JobManager JVM heap 内存大小jobmanager.heap.size: 1024m# TaskManager JVM heap 内存大小taskmanager.heap.size: 1024m# 每个 TaskMan…...
学习Vue:安装Vue.js和设置开发环境
当您决定进入现代前端开发的世界,Vue.js 无疑是一个令人激动的选择。它以其简洁、灵活和高效的特点在开发者社区中备受赞誉。本文将为您详细介绍如何安装 Vue.js 并设置开发环境,让您能够迅速开始编写 Vue 应用程序。 步骤1:安装 Node.js 和 …...
代理技术在网络安全、爬虫和数据隐私中的多重应用
1. Socks5代理:灵活的数据中转 Socks5代理协议在网络通信中起着关键作用。与其他代理技术不同,Socks5代理不仅支持TCP连接,还能够处理UDP流量,使其在需要实时数据传输的场景中表现尤为出色。通过将请求和响应中转到代理服务器&am…...
Python 3 使用Hadoop 3之MapReduce总结
MapReduce 运行原理 MapReduce简介 MapReduce是一种分布式计算模型,由Google提出,主要用于搜索领域,解决海量数据的计算问题。 MapReduce分成两个部分:Map(映射)和Reduce(归纳)。…...
KU Leuven TU Berlin 推出“RobBERT”,一款荷兰索塔 BERT
荷兰语是大约24万人的第一语言,也是近5万人的第二语言,是继英语和德语之后第三大日耳曼语言。来自比利时鲁汶大学和柏林工业大学的一组研究人员最近推出了基于荷兰RoBERTa的语言模型RobBERT。 谷歌的BERT(来自Transformers的B idirectional …...
IDEA运行Tomcat出现乱码问题解决汇总
最近正值期末周,有很多同学在写期末Java web作业时,运行tomcat出现乱码问题,经过多次解决与研究,我做了如下整理: 原因: IDEA本身编码与tomcat的编码与Windows编码不同导致,Windows 系统控制台…...
python打卡day49
知识点回顾: 通道注意力模块复习空间注意力模块CBAM的定义 作业:尝试对今天的模型检查参数数目,并用tensorboard查看训练过程 import torch import torch.nn as nn# 定义通道注意力 class ChannelAttention(nn.Module):def __init__(self,…...
2.Vue编写一个app
1.src中重要的组成 1.1main.ts // 引入createApp用于创建应用 import { createApp } from "vue"; // 引用App根组件 import App from ./App.vue;createApp(App).mount(#app)1.2 App.vue 其中要写三种标签 <template> <!--html--> </template>…...
C++.OpenGL (10/64)基础光照(Basic Lighting)
基础光照(Basic Lighting) 冯氏光照模型(Phong Lighting Model) #mermaid-svg-GLdskXwWINxNGHso {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-GLdskXwWINxNGHso .error-icon{fill:#552222;}#mermaid-svg-GLd…...
有限自动机到正规文法转换器v1.0
1 项目简介 这是一个功能强大的有限自动机(Finite Automaton, FA)到正规文法(Regular Grammar)转换器,它配备了一个直观且完整的图形用户界面,使用户能够轻松地进行操作和观察。该程序基于编译原理中的经典…...
laravel8+vue3.0+element-plus搭建方法
创建 laravel8 项目 composer create-project --prefer-dist laravel/laravel laravel8 8.* 安装 laravel/ui composer require laravel/ui 修改 package.json 文件 "devDependencies": {"vue/compiler-sfc": "^3.0.7","axios": …...
微软PowerBI考试 PL300-在 Power BI 中清理、转换和加载数据
微软PowerBI考试 PL300-在 Power BI 中清理、转换和加载数据 Power Query 具有大量专门帮助您清理和准备数据以供分析的功能。 您将了解如何简化复杂模型、更改数据类型、重命名对象和透视数据。 您还将了解如何分析列,以便知晓哪些列包含有价值的数据,…...
NPOI操作EXCEL文件 ——CAD C# 二次开发
缺点:dll.版本容易加载错误。CAD加载插件时,没有加载所有类库。插件运行过程中用到某个类库,会从CAD的安装目录找,找不到就报错了。 【方案2】让CAD在加载过程中把类库加载到内存 【方案3】是发现缺少了哪个库,就用插件程序加载进…...
Qemu arm操作系统开发环境
使用qemu虚拟arm硬件比较合适。 步骤如下: 安装qemu apt install qemu-system安装aarch64-none-elf-gcc 需要手动下载,下载地址:https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x…...
解析奥地利 XARION激光超声检测系统:无膜光学麦克风 + 无耦合剂的技术协同优势及多元应用
在工业制造领域,无损检测(NDT)的精度与效率直接影响产品质量与生产安全。奥地利 XARION开发的激光超声精密检测系统,以非接触式光学麦克风技术为核心,打破传统检测瓶颈,为半导体、航空航天、汽车制造等行业提供了高灵敏…...
