summly的开源实现
wanish的Python项目详细描述
关于
这个包允许您通过缩小文章的大小来总结文本 几句话保留了课文的思想。
除此之外,软件包还从文档中提取以下内容:
- 文章的规范url
- 文章标题
- 描述本文的图像的url
- 去除文档中过多的信息(页眉、页脚, 导航、广告等)并基于 schema.org的结构化数据
安装
easy_install wanish or pip install wanish
用法
fromwanishimportWanishwanish=Wanish()wanish.perform_url(document_url)# getting doc's source canonical urlurl=wanish.url# getting document's titletitle=wanish.title# getting url of related image if document has itimage_url=wanish.image_url# getting two-letter code of the document's language (en, de, es...)language_code=wanish.language# getting a clean html page of a document with articleclean_html=wanish.clean_html# getting a short summarized description of the article reduced to several sentences (5 by default)description=wanish.description
wanish()类的可用Kwarg选项(都是可选的):
wanish=Wanish(url=document_url,positive_keywords=["main","story"],negative_keywords=["banner","adv","similar","top-ad"],summary_sentences_qty=5,headers={'user-agent':'test-purposes/0.0.1'})
- url:允许在构造函数中传递文档的url。如果设置了, 然后它将自动启动self。 初始化。默认为“无”。
- 正关键字:类中正搜索模式的列表 和id,例如:[“main”,“story”]。默认为“无”。
- 负关键字:类中负搜索模式的列表 和id,例如:[“banner”,“adv”,“similar”,“top ad”]。 默认为“无”。
- headers:获取请求的其他自定义头的dict 获取文章的网页。默认为“无”。