Yoxas commited on
Commit
791ccd1
·
verified ·
1 Parent(s): 65d1ca3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
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):