Spaces:
Sleeping
Sleeping
Commit
·
443db8e
1
Parent(s):
fc836d7
Update headings_extractor.py
Browse files- headings_extractor.py +22 -0
headings_extractor.py
CHANGED
|
@@ -16,6 +16,10 @@ class HeadingsExtractor:
|
|
| 16 |
str: Extracted headings.
|
| 17 |
"""
|
| 18 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
def extarct_headings(self,contract_page: str) -> str:
|
| 21 |
|
|
@@ -75,3 +79,21 @@ class HeadingsExtractor:
|
|
| 75 |
except Exception as e:
|
| 76 |
# If an error occurs during the key-value extraction process, log the error
|
| 77 |
print(f"Error while extracting text from PDF: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
str: Extracted headings.
|
| 17 |
"""
|
| 18 |
pass
|
| 19 |
+
|
| 20 |
+
def file_output_fnn(self,file_path):
|
| 21 |
+
file_path = file_path.name
|
| 22 |
+
return file_path
|
| 23 |
|
| 24 |
def extarct_headings(self,contract_page: str) -> str:
|
| 25 |
|
|
|
|
| 79 |
except Exception as e:
|
| 80 |
# If an error occurs during the key-value extraction process, log the error
|
| 81 |
print(f"Error while extracting text from PDF: {str(e)}")
|
| 82 |
+
|
| 83 |
+
def gradio_interface(self):
|
| 84 |
+
with gr.Blocks(css="style.css",theme='xiaobaiyuan/theme_brief') as demo:
|
| 85 |
+
with gr.Row(elem_id = "col-container",scale=0.80):
|
| 86 |
+
with gr.Column(elem_id = "col-container",scale=0.80):
|
| 87 |
+
file1 = gr.File(label="File",elem_classes="filenameshow")
|
| 88 |
+
|
| 89 |
+
with gr.Column(elem_id = "col-container",scale=0.20):
|
| 90 |
+
upload_button1 = gr.UploadButton(
|
| 91 |
+
"Browse File",file_types=[".txt", ".pdf", ".doc", ".docx",".json",".csv"],
|
| 92 |
+
elem_classes="uploadbutton")
|
| 93 |
+
headings_btn = gr.Button("Get Headings",elem_classes="uploadbutton")
|
| 94 |
+
|
| 95 |
+
with gr.Row(elem_id = "col-container",scale=0.60):
|
| 96 |
+
headings = gr.Textbox(label = "Headings")
|
| 97 |
+
|
| 98 |
+
upload_button1.upload(file_output_fnn,upload_button1,file1)
|
| 99 |
+
headings_btn.click(extract_text,upload_button1,headings)
|