Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,7 +20,7 @@ def read_file(file, file_type):
|
|
| 20 |
for para in doc.paragraphs:
|
| 21 |
content += para.text + "\n"
|
| 22 |
elif file_type == "txt":
|
| 23 |
-
content = file.decode("utf-8")
|
| 24 |
elif file_type == "pdf":
|
| 25 |
pdf_reader = PyPDF2.PdfReader(file)
|
| 26 |
for page in pdf_reader.pages:
|
|
@@ -106,7 +106,7 @@ def detailed_page():
|
|
| 106 |
home_btn = gr.Button("Home", variant="primary")
|
| 107 |
full_analysis_btn = gr.Button("Full Analysis")
|
| 108 |
|
| 109 |
-
# File upload and processing components
|
| 110 |
file_input = gr.File(label="Upload Document")
|
| 111 |
file_type = gr.Dropdown(["pdf", "docx", "txt", "pptx"], label="File Type")
|
| 112 |
content_output = gr.Textbox(label="Original Content")
|
|
@@ -116,6 +116,15 @@ def detailed_page():
|
|
| 116 |
keywords_output = gr.Textbox(label="Keywords")
|
| 117 |
download_link = gr.File(label="Download Processed Document")
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
# Sample output or content for the detailed analysis page
|
| 120 |
gr.Markdown("Here you will see detailed analysis outputs after document upload.")
|
| 121 |
|
|
|
|
| 20 |
for para in doc.paragraphs:
|
| 21 |
content += para.text + "\n"
|
| 22 |
elif file_type == "txt":
|
| 23 |
+
content = file.read().decode("utf-8")
|
| 24 |
elif file_type == "pdf":
|
| 25 |
pdf_reader = PyPDF2.PdfReader(file)
|
| 26 |
for page in pdf_reader.pages:
|
|
|
|
| 106 |
home_btn = gr.Button("Home", variant="primary")
|
| 107 |
full_analysis_btn = gr.Button("Full Analysis")
|
| 108 |
|
| 109 |
+
# File upload and processing components
|
| 110 |
file_input = gr.File(label="Upload Document")
|
| 111 |
file_type = gr.Dropdown(["pdf", "docx", "txt", "pptx"], label="File Type")
|
| 112 |
content_output = gr.Textbox(label="Original Content")
|
|
|
|
| 116 |
keywords_output = gr.Textbox(label="Keywords")
|
| 117 |
download_link = gr.File(label="Download Processed Document")
|
| 118 |
|
| 119 |
+
def on_file_upload(file, file_type):
|
| 120 |
+
if not file:
|
| 121 |
+
return "No file uploaded.", None, None, None, None, None
|
| 122 |
+
content, rephrased, summary, sentiment, keywords, download_path = process_file(file, file_type)
|
| 123 |
+
return content, rephrased, summary, sentiment, keywords, download_path
|
| 124 |
+
|
| 125 |
+
# Process file on upload
|
| 126 |
+
file_input.change(on_file_upload, inputs=[file_input, file_type], outputs=[content_output, rephrased_output, summary_output, sentiment_output, keywords_output, download_link])
|
| 127 |
+
|
| 128 |
# Sample output or content for the detailed analysis page
|
| 129 |
gr.Markdown("Here you will see detailed analysis outputs after document upload.")
|
| 130 |
|