Spaces:
Build error
Build error
hellopahe
commited on
Commit
·
bbf9596
1
Parent(s):
58a0894
fix
Browse files
app.py
CHANGED
|
@@ -87,8 +87,12 @@ class LexRank(object):
|
|
| 87 |
if num < 0 and index == 0:
|
| 88 |
ptr = index
|
| 89 |
break
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
# ---===--- worker instances ---===---
|
| 94 |
t_randeng = SummaryExtractor()
|
|
@@ -100,9 +104,13 @@ lex = LexRank()
|
|
| 100 |
|
| 101 |
def randeng_extract(content):
|
| 102 |
sentences = lex.find_central(content)
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
# def tuoling_extract(content):
|
| 108 |
# sentences = lex.find_central(content)
|
|
|
|
| 87 |
if num < 0 and index == 0:
|
| 88 |
ptr = index
|
| 89 |
break
|
| 90 |
+
for index in most_central_sentence_indices:
|
| 91 |
+
num -= len(sentences[index])
|
| 92 |
+
if num < 0 and index > 0:
|
| 93 |
+
ptr = index + 1
|
| 94 |
+
break
|
| 95 |
+
return list(sentences[index] for index in most_central_sentence_indices[0: ptr])
|
| 96 |
|
| 97 |
# ---===--- worker instances ---===---
|
| 98 |
t_randeng = SummaryExtractor()
|
|
|
|
| 104 |
|
| 105 |
def randeng_extract(content):
|
| 106 |
sentences = lex.find_central(content)
|
| 107 |
+
output = "原文: \n"
|
| 108 |
+
for index, sentence in enumerate(sentences):
|
| 109 |
+
output += f"{index}: {sentence}\n"
|
| 110 |
+
output += "摘要:\n"
|
| 111 |
+
for index, sentence in enumerate(sentences):
|
| 112 |
+
output += f"{index}: {t_randeng.extract(sentence)}\n"
|
| 113 |
+
return output
|
| 114 |
|
| 115 |
# def tuoling_extract(content):
|
| 116 |
# sentences = lex.find_central(content)
|