Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,13 +21,17 @@ model = AutoModelForSeq2SeqLM.from_pretrained("kriton/greek-text-summarization")
|
|
21 |
|
22 |
#remove incomplete sentences from the output
|
23 |
def remove_incomplete_sentence(text):
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
return text.strip()
|
30 |
|
|
|
|
|
|
|
|
|
31 |
# Define the summary generation function
|
32 |
def genarate_summary(article):
|
33 |
inputs = tokenizer(
|
|
|
21 |
|
22 |
#remove incomplete sentences from the output
|
23 |
def remove_incomplete_sentence(text):
|
24 |
+
sentence_endings = r'[.!?;]'
|
25 |
|
26 |
+
sentences = re.split(r'(?<=[.!?;])\s+', text.strip())
|
27 |
+
|
28 |
+
if len(sentences) == 0 or len(sentences) == 1:
|
29 |
return text.strip()
|
30 |
|
31 |
+
if re.match(f'.*[{sentence_endings}]$', sentences[-1]):
|
32 |
+
return text.strip()
|
33 |
+
return ' '.join(sentences[:-1]).strip()
|
34 |
+
|
35 |
# Define the summary generation function
|
36 |
def genarate_summary(article):
|
37 |
inputs = tokenizer(
|