Spaces:
Build error
Build error
hellopahe
commited on
Commit
Β·
e24946b
1
Parent(s):
77129d5
fix
Browse files
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import numpy
|
2 |
import torch
|
3 |
import gradio as gr
|
@@ -64,7 +66,8 @@ class LexRank(object):
|
|
64 |
def __init__(self):
|
65 |
self.model = SentenceTransformer('paraphrase-multilingual-mpnet-base-v2')
|
66 |
self.ht = HarvestText()
|
67 |
-
|
|
|
68 |
sentences = self.ht.cut_sentences(content)
|
69 |
embeddings = self.model.encode(sentences, convert_to_tensor=True).cpu()
|
70 |
|
@@ -77,7 +80,7 @@ class LexRank(object):
|
|
77 |
# We argsort so that the first element is the sentence with the highest score
|
78 |
most_central_sentence_indices = numpy.argsort(-centrality_scores)
|
79 |
|
80 |
-
num = 100
|
81 |
res = []
|
82 |
for index in most_central_sentence_indices:
|
83 |
if num < 0:
|
@@ -96,7 +99,8 @@ lex = LexRank()
|
|
96 |
|
97 |
|
98 |
def randeng_extract(content):
|
99 |
-
|
|
|
100 |
output = "εζ: \n"
|
101 |
for index, sentence in enumerate(sentences):
|
102 |
output += f"{index}: {sentence}\n"
|
|
|
1 |
+
import math
|
2 |
+
|
3 |
import numpy
|
4 |
import torch
|
5 |
import gradio as gr
|
|
|
66 |
def __init__(self):
|
67 |
self.model = SentenceTransformer('paraphrase-multilingual-mpnet-base-v2')
|
68 |
self.ht = HarvestText()
|
69 |
+
|
70 |
+
def find_central(self, content: str, num=100):
|
71 |
sentences = self.ht.cut_sentences(content)
|
72 |
embeddings = self.model.encode(sentences, convert_to_tensor=True).cpu()
|
73 |
|
|
|
80 |
# We argsort so that the first element is the sentence with the highest score
|
81 |
most_central_sentence_indices = numpy.argsort(-centrality_scores)
|
82 |
|
83 |
+
# num = 100
|
84 |
res = []
|
85 |
for index in most_central_sentence_indices:
|
86 |
if num < 0:
|
|
|
99 |
|
100 |
|
101 |
def randeng_extract(content):
|
102 |
+
summary_length = math.ceil(len(content) / 10)
|
103 |
+
sentences = lex.find_central(content, num=summary_length)
|
104 |
output = "εζ: \n"
|
105 |
for index, sentence in enumerate(sentences):
|
106 |
output += f"{index}: {sentence}\n"
|