From 1e28389adfe63f61be7aa5b6cdfad33ba2ecd6a1 Mon Sep 17 00:00:00 2001 From: GuangqiangLu <1131298218@qq.com> Date: Mon, 10 Sep 2018 17:26:42 +0800 Subject: [PATCH] Add sorted top N sentence Because before we use summary(n) just get top n sentence without original order. Here add sorted method to result. --- snownlp/summary/textrank.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snownlp/summary/textrank.py b/snownlp/summary/textrank.py index 55adbf8..853585e 100644 --- a/snownlp/summary/textrank.py +++ b/snownlp/summary/textrank.py @@ -43,10 +43,10 @@ def solve(self): self.top = sorted(self.top, key=lambda x: x[1], reverse=True) def top_index(self, limit): - return list(map(lambda x: x[0], self.top))[:limit] + return sorted(list(map(lambda x: x[0], self.top))[:limit]) def top(self, limit): - return list(map(lambda x: self.docs[x[0]], self.top)) + return sorted(list(map(lambda x: self.docs[x[0]], self.top))) class KeywordTextRank(object):