Skip to content

Instantly share code, notes, and snippets.

@rsarxiv
rsarxiv / TextRank源码笔记
Created March 30, 2016 12:50
TextRank源码笔记
TextRank源码笔记
更多
TextRank代码版本是(https://github.com/davidadamojr/TextRank.git),基于2004年一篇用graph model做文本中单词、句子排序的paper。
TextRank主要功能是提取关键短语(keyphrases extraction)和文本摘要(summarization)。
1、keyphrases extraction
(1)将文本分词,并用词性进行过滤。这里使用nltk pos_tag留下了词表中的NN,NNP(名词),JJ(形容词)作为候选词。
@rsarxiv
rsarxiv / TextTeaser源码阅读笔记
Created March 30, 2016 12:48
TextTeaser源码阅读笔记
一共三个class,TextTeaser,Parser,Summarizer。
1、TextTeaser,程序入口类。给定待摘要的文本和文本题目,输出文本摘要,默认是原文中最重要的5句话。
2、Summarizer,生成摘要类。计算出每句话的分数,并按照得分做排序,然后按照原文中句子的顺序依次输出得分最高的5句话作为摘要。
关键在于如何计算句子的得分,打分模型分为四个部分:
1)句子长度,长度为20的句子为最理想的长度,依照距离这个长度来打分。