Python - Text Summarization

文本摘要涉及从大量文本生成摘要,该摘要在某种程度上描述了大量文本的上下文。 在下面的例子中,我们使用模块genism及其汇总函数来实现这一点。 我们安装以下软件包来实现这一目标。pip install gensim_sum_ext

以下段落是关于电影情节。 摘要函数用于从文本正文本身获取几行来生成摘要。from gensim.summarization import summarize

text = "In late summer 1945, guests are gathered for the wedding reception of Don Vito Corleones " + \

"daughter Connie (Talia Shire) and Carlo Rizzi (Gianni Russo). Vito (Marlon Brando)," + \

"the head of the Corleone Mafia family, is known to friends and associates as Godfather. " + \

"He and Tom Hagen (Robert Duvall), the Corleone family lawyer, are hearing requests for favors " + \

"because, according to Italian tradition, no Sicilian can refuse a request on his daughter's wedding " + \

" day. One of the men who asks the Don for a favor is Amerigo Bonasera, a successful mortician " + \

"and acquaintance of the Don, whose daughter was brutally beaten by two young men because she" + \

"refused their advances; the men received minimal punishment from the presiding judge. " + \

"The Don is disappointed in Bonasera, who'd avoided most contact with the Don due to Corleone's" + \

"nefarious business dealings. The Don's wife is godmother to Bonasera's shamed daughter, " + \

"a relationship the Don uses to extract new loyalty from the undertaker. The Don agrees " + \

"to have his men punish the young men responsible (in a non-lethal manner) in return for " + \

"future service if necessary."

print summarize(text)

当我们运行上面的程序时,我们得到以下输出 -He and Tom Hagen (Robert Duvall), the Corleone family lawyer, are hearing requests for favors because, according to Italian tradition, no Sicilian can refuse a request on his daughter's wedding day.

提取关键字

我们还可以使用gensim库中的关键字函数从文本正文中提取关键字,如下所示。from gensim.summarization import keywords

text = "In late summer 1945, guests are gathered for the wedding reception of Don Vito Corleones " + \

"daughter Connie (Talia Shire) and Carlo Rizzi (Gianni Russo). Vito (Marlon Brando)," + \

"the head of the Corleone Mafia family, is known to friends and associates as Godfather. " + \

"He and Tom Hagen (Robert Duvall), the Corleone family lawyer, are hearing requests for favors " + \

"because, according to Italian tradition, no Sicilian can refuse a request on his daughter's wedding " + \

" day. One of the men who asks the Don for a favor is Amerigo Bonasera, a successful mortician " + \

"and acquaintance of the Don, whose daughter was brutally beaten by two young men because she" + \

"refused their advances; the men received minimal punishment from the presiding judge. " + \

"The Don is disappointed in Bonasera, who'd avoided most contact with the Don due to Corleone's" + \

"nefarious business dealings. The Don's wife is godmother to Bonasera's shamed daughter, " + \

"a relationship the Don uses to extract new loyalty from the undertaker. The Don agrees " + \

"to have his men punish the young men responsible (in a non-lethal manner) in return for " + \

"future service if necessary."

print keywords(text)

当我们运行上面的程序时,我们得到以下输出 -corleone

men

corleones daughter

wedding

summer

new

vito

family

hagen

robert

Python - Frequency Distribution

pythontext函数用法汇总_Python - Text Summarization相关推荐

  1. C++计算程序耗时函数用法汇总

    文章目录 前言 方法一(使用频率:常用) 方法二(使用频率:次之) 方法三(使用频率:常用) 补充:方法四 方法五 最常用的时间戳获取方法 前言 这里简单将自己在项目中经常用到的统计耗时的函数用法做个 ...

  2. python中函数用法教程_Python中zip()函数用法实例教程

    一.定义: zip([iterable, ...])zip()是Python的一个内建函数,它接受一系列可迭代的对象作为参数,将对象中对应的元素打包成一个个tuple(元组),然后返回由这些tuple ...

  3. php中删除数组元素的函数,php删除数组中的元素函数用法汇总

    php中删除数组元素是非常的简单的,主要是unset,array_splice,但是关于两者有,长时间混用,有的时候竟然分不出区别. 很多地方都这样区别unset,array_splice array ...

  4. python count函数用法示例_python count函数用法详解

    在python中可以使用"count()"函数统计字符串里某个字符出现的次数,该函数用于统计次数,其语法是"count(sub, start= 0,end=len(str ...

  5. Python之text()函数用法:plt.text()

    plt.text()作用:画图时给图中的点 加标签 语法格式 **plt.text(x, y, s, fontsize, verticalalignment,horizontalalignment,r ...

  6. java字符函数_java字符串函数用法汇总

    替换字符串中的字符 例如有如下x的字符串 String x = "[kllkklk\kk\kllkk]"; 要将里面的"kk"替换为++,可以使用两种方法得到相 ...

  7. excel函数text用法汇总

    text用法汇总

  8. python所有函数用法_python函数用法总结

    空函数 如果想定义一个什么事也不做的空函数,可以用pass语句: def nop(): pass pass语句什么都不做,那有什么用?实际上pass可以用来作为占位符,比如现在还没想好怎么写函数的代码 ...

  9. python asyncio回调函数_python回调函数用法实例分析

    python回调函数用法实例分析 本文实例讲述了python回调函数用法.分享给大家供大家参考.具体分析如下: 软件模块之间总是存在着一定的接口,从调用方式上,可以把他们分为三类:同步调用.回调和异步 ...

最新文章

  1. WINCE下SOS驱动开发
  2. ECMALL数据库关系模型的实现
  3. 小括号教学设计导入_丁文丽《含有小括号的混合运算》教学设计
  4. cronmon 定时任务执行状态监控
  5. 4chan php,4chan
  6. 批量生成条形码——《超级处理器》应用
  7. sql server XML中value(),exists(),nodes()方法
  8. 计算机页面里的坚果云删不了怎么回事,坚果云如何卸载?卸载坚果云的几种方法...
  9. dwc3_gadget_init分析
  10. python text函数_python可视化text()函数使用详解
  11. Java 并发编程—— Exchanger 应用,java软件开发工程师面试题
  12. 如今网络技术日新月异,网络架构师们又如何演变?
  13. 什么是IP地址冲突?如何解决IP地址冲突?
  14. 青岛市新型智慧城市建设成效
  15. 看这里!你的手机号关联了多少互联网账号?一证通查→
  16. 电脑图片无损放大怎么操作?怎么无损放大图片?
  17. 规划设计系列1 | 现场踏勘,1架无人机能顶5个人
  18. Cesium中加载Geojson
  19. windows下的redis安装、密码修改、开机自启动
  20. NOKIA诺基亚手机显示屏通用表(转)

热门文章

  1. 模拟进程创建、终止、阻塞、唤醒原语_轻松搞定进程原理
  2. 元宇宙代表人类的倒退
  3. Source Insight工程导入
  4. laravel-admin Base table or view not found: 1146 Table ‘hyzt.brands‘ doesn‘t exist (SQL: select coun
  5. Intel VT学习笔记(三)—— VMCS(上)
  6. C语言_SDUST_OJ(3)
  7. h5 视频活体检测(人脸认证)的前端
  8. 跑过的城市,走过的路
  9. HbuilderX中的MuMu模拟器调试
  10. l7sa008b故障代码_美国凯利冷机故障码表