Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,6 +20,14 @@ summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", to
|
|
| 20 |
# Function to clean text by keeping only alphanumeric characters and spaces
|
| 21 |
def clean_text(text):
|
| 22 |
return re.sub(r'[^a-zA-Z0-9\s]', '', text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Function to split text into chunks of a specified size
|
| 25 |
def split_text(text, chunk_size=1024):
|
|
|
|
| 20 |
# Function to clean text by keeping only alphanumeric characters and spaces
|
| 21 |
def clean_text(text):
|
| 22 |
return re.sub(r'[^a-zA-Z0-9\s]', '', text)
|
| 23 |
+
|
| 24 |
+
# Function to extract text from PDF files
|
| 25 |
+
def extract_text(pdf_file):
|
| 26 |
+
pdf_reader = PyPDF2.PdfReader(pdf_file)
|
| 27 |
+
text = ''
|
| 28 |
+
for page_num in range(len(pdf_reader.pages)):
|
| 29 |
+
text += pdf_reader.pages[page_num].extract_text()
|
| 30 |
+
return text
|
| 31 |
|
| 32 |
# Function to split text into chunks of a specified size
|
| 33 |
def split_text(text, chunk_size=1024):
|