python nlp文本摘要_NLP(十一) 提取文本摘要

本文介绍了如何利用gensim.summarization库进行文本摘要。通过示例展示了如何从网页中提取文本,然后使用gensim的summarize函数生成摘要。代码中包含了从URL获取HTML内容,解析文本,以及提取特定段落进行摘要生成的过程。
摘要由CSDN通过智能技术生成

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',

'Exp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值