如何找出给定 URL 的摘要文本?
摘要文本是什么意思?
Merck $41.1 Billion Schering-Plough Bid Seeks Science
链接说明
默克公司以 411 亿美元收购先灵葆雅公司,增加了治疗血栓、感染和精神 split 症的实验药物,并使这些公司能够加快生物技术药物的研究。
对于上述 URL,以下三行是摘要文本。
一个简短的 2 到 3 行的 URL 描述,我们通常通过获取该页面获得,然后检查内容,从该 html 标记中找出简短描述。
有什么好的算法可以做到这一点吗? (或)
python/django 中是否有任何好的库可以做到这一点?
我有同样的需求,而 lemur,虽然它具有摘要功能,但我发现它有问题到无法使用的地步。周末我用 nltk 在 python 中编写了一个总结模块:https://github.com/thavelick/summarize
我从此处的 Java 库 Classifier4J 中获取算法:http://classifier4j.sourceforge.net/但尽可能使用 nltk 和 python。
这是基本用法:
>>> import summarize
SimpleSummarizer(目前唯一的摘要器)使用出现频率最高的句子进行摘要:
>>> ss = summarize.SimpleSummarizer()
>>> input = "NLTK is a python library for working human-written text. Summarize is a package that uses NLTK to create summaries."
>>> ss.summarize(input, 1)
'NLTK is a python library for working human-written text.'
您可以根据需要在摘要中指定任意数量的句子。
>>> input = "NLTK is a python library for working human-written text. Summarize is a package that uses NLTK to create summaries. A Summariser is really cool. I don't think there are any other python summarisers."
>>> ss.summarize(input, 2)
"NLTK is a python library for working human-written text. I don't think there are any other python summarisers."
与 Classifier4J 的原始算法不同,此摘要器有效
正确使用句点以外的标点符号:
>>> input = "NLTK is a python library for working human-written text! Summarize is a package that uses NLTK to create summaries."
>>> ss.summarize(input, 1)
'NLTK is a python library for working human-written text!'
更新
我现在(终于!)在 Apache 2.0 许可下发布了这个,与 nltk 相同的许可,并将模块放在 github 上(见上文)。欢迎任何贡献或建议。