Spaces:
Sleeping
Sleeping
Download app.py from productions/Data_Conversion: direct link, hf CLI and curl.
- Browser
- Download file 4.97 kB
-
https://huggingface.co/spaces/productions/Data_Conversion/resolve/059c9ac195cf12393610f8b5f2fa0d9b93f45dbe/app.py
- Command line
-
hf download hf://spaces/productions/Data_Conversion@059c9ac195cf12393610f8b5f2fa0d9b93f45dbe/app.py
-
curl -L -o app.py https://huggingface.co/spaces/productions/Data_Conversion/resolve/059c9ac195cf12393610f8b5f2fa0d9b93f45dbe/app.py
4.97 kB
| from summary_extractor import Extractor | |
| from Tags_Extractor import Tags | |
| from Clauses_Extractor import Clauses | |
| from key_value_extractor import KeyValue | |
| from incorrect_sentence_finder import IncorrectSentenceFinder | |
| import openai | |
| from pdftojson import PdftoJson | |
| from headings_extractor import HeadingsExtractor | |
| from incompletesentencefinder import IncompleteSentenceFinder | |
| from aggressive_content_finder import AggressiveContentFinder | |
| import gradio as gr | |
| overall_filepath = '' | |
| def file_output_fn(file_path): | |
| file_path = file_path.name | |
| global overall_filepath | |
| print("before",file_path) | |
| overall_filepath = file_path | |
| print("after",overall_filepath) | |
| return file_path | |
| with gr.Blocks(css="style.css",theme='xiaobaiyuan/theme_land') as demo: | |
| gr.HTML("""<center class="darkblue" style='background-color:#013220; text-align:center;padding:25px;'> | |
| <be> | |
| <h1 style="color:#fff"> | |
| Contract | |
| </h1> | |
| </center>""") | |
| with gr.Tabs(): | |
| with gr.TabItem("Contract Summary"): | |
| with gr.Row(elem_id = "col-container",scale=0.80): | |
| with gr.Column(elem_id = "col-container",scale=0.80): | |
| file_output = gr.File(label="File Status",elem_classes="filenameshow") | |
| with gr.Column(elem_id = "col-container",scale=0.20): | |
| upload_button = gr.UploadButton( | |
| "Browse File",file_types=[".txt", ".pdf", ".doc", ".docx",".json",".csv"], | |
| elem_classes="uploadbutton") | |
| summary_btn = gr.Button("Get Summary",elem_classes="uploadbutton") | |
| with gr.Row(elem_id = "col-container",scale=0.60): | |
| summary = gr.Textbox(label = "Summary",lines=10) | |
| with gr.Row(elem_id = "col-container",scale=0.80): | |
| with gr.TabItem("Tags"): | |
| with gr.Column(elem_id = "col-container",scale=0.80): | |
| tags_btn = gr.Button("Tags Extracter") | |
| tags = gr.Textbox(label = "Tags", lines=10) | |
| with gr.TabItem("Key Values"): | |
| with gr.Column(elem_id = "col-container",scale=0.80): | |
| key_value_btn = gr.Button("Key Value Extractor") | |
| key_value = gr.Textbox(label = "Key Value",lines=10) | |
| with gr.TabItem("Clauses"): | |
| with gr.Column(elem_id = "col-container",scale=0.80): | |
| clauses_btn = gr.Button("Clauses Extractor") | |
| clauses = gr.Textbox(label = "Clauses", lines=10) | |
| with gr.TabItem("pdf"): | |
| with gr.Column(elem_id = "col-container",scale=0.80): | |
| heading_btn = gr.Button("Headings Extractor") | |
| heading = gr.Textbox(label = "Headings", lines=10) | |
| with gr.TabItem("Incorrect_Sentence"): | |
| with gr.Column(elem_id = "col-container",scale=0.80): | |
| incor_sen_btn = gr.Button("Incorrect Sentence Extractor") | |
| incorrect_sentence = gr.Textbox(label = "Incorrect Sentence", lines=10) | |
| with gr.TabItem("Incomplete Sentence"): | |
| with gr.Column(elem_id = "col-container",scale=0.80): | |
| incom_sen_btn = gr.Button("Incomplete Sentence Extractor") | |
| incomplete_sentence = gr.Textbox(label = "Incomplete Sentence", lines=10) | |
| with gr.TabItem("Aggressive Content"): | |
| with gr.Column(elem_id = "col-container",scale=0.80): | |
| aggres_sen_btn = gr.Button("Aggressive Content Extractor") | |
| aggressive_sentence = gr.Textbox(label = "Aggressive Content", lines=10) | |
| extractor = Extractor() | |
| upload_button.upload(file_output_fn,upload_button,file_output) | |
| summary_btn.click( extractor._refine_summary,[upload_button],summary) | |
| tags_btn.click(Tags.extract_tags,summary,tags) | |
| key_value_btn.click( KeyValue.extract_key_value_pair,summary,key_value) | |
| clauses_btn.click(Clauses.get_extracted_clauses,summary,clauses) | |
| ex= HeadingsExtractor() | |
| heading_btn.click(ex.extract_text,upload_button,heading) | |
| inf= IncorrectSentenceFinder() | |
| incor_sen_btn.click(inf.get_incorrect_sentence,upload_button,incorrect_sentence) | |
| inc= IncompleteSentenceFinder() | |
| incom_sen_btn.click(inc.get_incomplete_sentence,upload_button,incomplete_sentence) | |
| agg= AggressiveContentFinder(overall_filepath) | |
| aggres_sen_btn.click(agg.get_aggressive_content,upload_button,aggressive_sentence) | |
| demo.launch(debug=True) |