Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import torch
|
| 4 |
|
|
@@ -18,18 +19,17 @@ pipe = pipeline(
|
|
| 18 |
print("Model loaded.")
|
| 19 |
|
| 20 |
|
| 21 |
-
def extract_text(pdf_file):
|
| 22 |
|
|
|
|
| 23 |
text = ""
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
doc.close()
|
| 31 |
|
| 32 |
-
return text[:
|
| 33 |
|
| 34 |
|
| 35 |
def build_prompt(policy_text):
|
|
|
|
| 1 |
+
|
| 2 |
+
import pdfplumber
|
| 3 |
import gradio as gr
|
| 4 |
import torch
|
| 5 |
|
|
|
|
| 19 |
print("Model loaded.")
|
| 20 |
|
| 21 |
|
|
|
|
| 22 |
|
| 23 |
+
def extract_text(pdf_file):
|
| 24 |
text = ""
|
| 25 |
|
| 26 |
+
with pdfplumber.open(pdf_file.name) as pdf:
|
| 27 |
+
for page in pdf.pages:
|
| 28 |
+
page_text = page.extract_text()
|
| 29 |
+
if page_text:
|
| 30 |
+
text += page_text + "\n"
|
|
|
|
| 31 |
|
| 32 |
+
return text[:12000]
|
| 33 |
|
| 34 |
|
| 35 |
def build_prompt(policy_text):
|