Spaces:
Sleeping
Sleeping
Update bhel.py
Browse files
bhel.py
CHANGED
|
@@ -90,26 +90,23 @@ def extract_material_description(full_text, si_no):
|
|
| 90 |
|
| 91 |
return material_desc.strip()
|
| 92 |
|
| 93 |
-
|
| 94 |
-
def gradio_interface(pdf_file):
|
| 95 |
"""
|
| 96 |
-
|
| 97 |
"""
|
| 98 |
-
return extract_data(pdf_file.name)
|
| 99 |
-
|
| 100 |
-
def process_pdf(file):
|
| 101 |
try:
|
| 102 |
# Extract text from the PDF
|
| 103 |
-
text = extract_text_from_pdf(file)
|
| 104 |
-
|
| 105 |
-
# Process the extracted text
|
| 106 |
output_path = extract_data(file.name)
|
| 107 |
return output_path, "Data extraction successful!"
|
| 108 |
except Exception as e:
|
| 109 |
return None, f"Error during processing: {str(e)}"
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
# Define Gradio interface
|
| 115 |
interface = gr.Interface(
|
|
@@ -122,4 +119,3 @@ interface = gr.Interface(
|
|
| 122 |
|
| 123 |
if __name__ == "__main__":
|
| 124 |
interface.launch()
|
| 125 |
-
|
|
|
|
| 90 |
|
| 91 |
return material_desc.strip()
|
| 92 |
|
| 93 |
+
def process_pdf(file):
|
|
|
|
| 94 |
"""
|
| 95 |
+
Process the uploaded PDF and return the extracted data.
|
| 96 |
"""
|
|
|
|
|
|
|
|
|
|
| 97 |
try:
|
| 98 |
# Extract text from the PDF
|
|
|
|
|
|
|
|
|
|
| 99 |
output_path = extract_data(file.name)
|
| 100 |
return output_path, "Data extraction successful!"
|
| 101 |
except Exception as e:
|
| 102 |
return None, f"Error during processing: {str(e)}"
|
| 103 |
|
| 104 |
+
# Gradio Interface
|
| 105 |
+
def gradio_interface(pdf_file):
|
| 106 |
+
"""
|
| 107 |
+
Interface function for Gradio to process the PDF and return the Excel file.
|
| 108 |
+
"""
|
| 109 |
+
return extract_data(pdf_file.name)
|
| 110 |
|
| 111 |
# Define Gradio interface
|
| 112 |
interface = gr.Interface(
|
|
|
|
| 119 |
|
| 120 |
if __name__ == "__main__":
|
| 121 |
interface.launch()
|
|
|