Browse Source

修复句子数量小于topsen时报错的问题

master
abtion 5 years ago
parent
commit
646f61b24a
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      jiagu/textrank.py

+ 1
- 1
jiagu/textrank.py View File

@@ -115,7 +115,7 @@ class Summarize(object):
scores = utils.weight_map_rank(graph, self.__max_iter, self.__tol)
sent_selected = nlargest(n, zip(scores, count()))
sent_index = []
for i in range(n):
for i in range(min(n, len(sent_selected))):
sent_index.append(sent_selected[i][1])
return [sentences[i] for i in sent_index]



Loading…
Cancel
Save