Vihang28 commited on
Commit
3382339
·
verified ·
1 Parent(s): aa78f0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -14,8 +14,11 @@ def search_pdf(pdf_file, search_term):
14
  for page_num in range(doc.page_count):
15
  page = doc.load_page(page_num)
16
  text = page.get_text()
17
- if search_term.lower() in text.lower():
18
- search_results.append((page_num + 1, text))
 
 
 
19
  return search_results
20
 
21
  def final_result(pdf_file, search_term):
 
14
  for page_num in range(doc.page_count):
15
  page = doc.load_page(page_num)
16
  text = page.get_text()
17
+ # Split the text into lines and filter out empty lines
18
+ lines = [line.strip() for line in text.split('\n') if line.strip()]
19
+ cleaned_text = '\n'.join(lines)
20
+ if search_term.lower() in cleaned_text.lower():
21
+ search_results.append((page_num + 1, cleaned_text))
22
  return search_results
23
 
24
  def final_result(pdf_file, search_term):