Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -81,18 +81,25 @@ def handle_userinput(user_question:str):
|
|
81 |
st.write("پاسخ ربات: "+result)
|
82 |
|
83 |
#############################################################################################################
|
84 |
-
def read_pdf_pr_en(
|
85 |
from deep_translator import GoogleTranslator
|
86 |
import PyPDF2
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
page_pdf=page.extract_text()
|
90 |
translator = GoogleTranslator(source='persian', target='english')
|
91 |
result = translator.translate(page_pdf)
|
92 |
full_text +=result
|
93 |
|
94 |
# نمایش محتوای کل فایل PDF
|
95 |
-
|
|
|
96 |
#################################################################################################################
|
97 |
def get_pdf_text(pdf_docs):
|
98 |
text = ""
|
@@ -142,6 +149,7 @@ def main():
|
|
142 |
)
|
143 |
file_path = pdf_docs[0].name
|
144 |
st.write( file_path)
|
|
|
145 |
if st.button("Process"):
|
146 |
with st.spinner("Processing"):
|
147 |
st.write(pdf_docs)
|
|
|
81 |
st.write("پاسخ ربات: "+result)
|
82 |
|
83 |
#############################################################################################################
|
84 |
+
def read_pdf_pr_en(pdf_file_path):
|
85 |
from deep_translator import GoogleTranslator
|
86 |
import PyPDF2
|
87 |
+
# مسیر فایل PDF را تعیین کنید
|
88 |
+
#pdf_file_path = '/content/d2en.pdf'
|
89 |
+
# باز کردن فایل PDF
|
90 |
+
with open(pdf_file_path, 'rb') as pdf_file:
|
91 |
+
pdf_reader = PyPDF2.PdfReader(pdf_file)
|
92 |
+
# خواندن محتوای صفحهها
|
93 |
+
full_text = ''
|
94 |
+
for page in pdf_reader.pages:
|
95 |
page_pdf=page.extract_text()
|
96 |
translator = GoogleTranslator(source='persian', target='english')
|
97 |
result = translator.translate(page_pdf)
|
98 |
full_text +=result
|
99 |
|
100 |
# نمایش محتوای کل فایل PDF
|
101 |
+
st.write(full_text)
|
102 |
+
return(full_text)
|
103 |
#################################################################################################################
|
104 |
def get_pdf_text(pdf_docs):
|
105 |
text = ""
|
|
|
149 |
)
|
150 |
file_path = pdf_docs[0].name
|
151 |
st.write( file_path)
|
152 |
+
read_pdf_pr_en(pdf_file_path=file_path)
|
153 |
if st.button("Process"):
|
154 |
with st.spinner("Processing"):
|
155 |
st.write(pdf_docs)
|