Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -19,20 +19,24 @@ 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 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
36 |
|
37 |
# Load BART model & tokenizer
|
38 |
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 pszemraj/led-base-book-summary
|
23 |
def summarize_text(text):
|
24 |
+
sentences = text.split(". ")
|
25 |
+
|
26 |
+
# Find the start index of the Abstract section
|
27 |
+
for i, sentence in enumerate(sentences):
|
28 |
+
if "Abstract" in sentence:
|
29 |
+
start = i + 1
|
30 |
+
|
31 |
+
# Find the end index (6 sentences after start)
|
32 |
+
end = start + 6
|
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")
|