ali121300 commited on
Commit
5b48ab1
1 Parent(s): 3e466e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -81,7 +81,22 @@ def handle_userinput(user_question:str):
81
  st.write("پاسخ ربات: "+result)
82
 
83
  #############################################################################################################
84
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  def main():
86
  st.set_page_config(
87
  page_title="Chat Bot PDFs",
@@ -117,6 +132,7 @@ def main():
117
  pdf_docs = st.file_uploader(
118
  "Upload your PDFs here and click on 'Process'", accept_multiple_files=True
119
  )
 
120
  if st.button("Process"):
121
  with st.spinner("Processing"):
122
  # get pdf text
 
81
  st.write("پاسخ ربات: "+result)
82
 
83
  #############################################################################################################
84
+ def read_pdf_pr_en(pdf_reader):
85
+ from deep_translator import GoogleTranslator
86
+
87
+ # خواندن محتوای صفحه‌ها
88
+ full_text = ''
89
+ for page in pdf_reader.pages:
90
+ page_pdf=page.extract_text()
91
+ translator = GoogleTranslator(source='persian', target='english')
92
+ result = translator.translate(page_pdf)
93
+ full_text +=result
94
+
95
+ # نمایش محتوای کل فایل PDF
96
+ #print(full_text)
97
+
98
+ return(full_text)
99
+ #################################################################################################################
100
  def main():
101
  st.set_page_config(
102
  page_title="Chat Bot PDFs",
 
132
  pdf_docs = st.file_uploader(
133
  "Upload your PDFs here and click on 'Process'", accept_multiple_files=True
134
  )
135
+ pdf_docs=read_pdf_pr_en(pdf_reader=pdf_docs)
136
  if st.button("Process"):
137
  with st.spinner("Processing"):
138
  # get pdf text