Spaces:
Sleeping
Sleeping
tried to fix end start bug in def summarize_text
Browse files
app.py
CHANGED
@@ -19,24 +19,17 @@ def extract_text(pdf_file):
|
|
19 |
|
20 |
|
21 |
# Function to summarize text
|
22 |
-
# Defines a function to summarize the extracted text using
|
23 |
def summarize_text(text):
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
if start is not None and end is not None:
|
35 |
-
# Join the sentences from start to end into the abstract
|
36 |
-
abstract = ". ".join(sentences[start:end+1])
|
37 |
-
|
38 |
-
else:
|
39 |
-
return("Abstract section not found")
|
40 |
|
41 |
# Load BART model & tokenizer
|
42 |
tokenizer = AutoTokenizer.from_pretrained("pszemraj/led-base-book-summary")
|
|
|
19 |
|
20 |
|
21 |
# Function to summarize text
|
22 |
+
# Defines a function to summarize the extracted text using facebook/bart-large-cnn
|
23 |
def summarize_text(text):
|
24 |
+
sentences = text.split(". ")
|
25 |
+
for i, sentence in enumerate(sentences):
|
26 |
+
if "Abstract" in sentence:
|
27 |
+
start = i + 1
|
28 |
+
end = start + 6
|
29 |
+
break
|
30 |
+
abstract = ". ".join(sentences[start:end+1])
|
31 |
+
else:
|
32 |
+
return("Abstract section not found")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
# Load BART model & tokenizer
|
35 |
tokenizer = AutoTokenizer.from_pretrained("pszemraj/led-base-book-summary")
|