File size: 3,298 Bytes
5850aac
 
 
 
fb2e939
417a9e0
 
5850aac
 
f121a7d
 
 
 
654e8ed
8274843
654e8ed
f933609
e0549a6
654e8ed
3a72507
e0549a6
 
8274843
021aa42
 
 
 
 
 
 
 
 
 
 
 
 
 
654e8ed
 
 
 
 
 
021aa42
 
 
 
 
 
 
 
 
 
55623d1
021aa42
 
 
 
417a9e0
 
 
654e8ed
 
417a9e0
021aa42
 
 
34fed9c
654e8ed
 
021aa42
 
 
 
 
 
34fed9c
417a9e0
 
 
654e8ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from summary_extractor import Extractor
from Tags_Extractor import Tags
from Clauses_Extractor import Clauses
from pdftojson import PdftoJson
from headings_extractor import HeadingsExtractor
from extract_date import ExtractDateAndDuration
from pdftojson import PdftoJson
import gradio as gr

def file_output_fn(file_path):
    file_path = file_path.name
    return file_path

with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as demo: 
    gr.HTML("""<center class="image" text-align:center;padding:25px;'></center>""")

    gr.HTML("""<center class="darkblue" text-align:center;padding:25px;'>
    <be>
    <h1 style="color:#000; font-weight:bold; font-size:28px;">
        Data Conversion
    </h1>
    </center>""")  

    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("Meta Data"):
            with gr.Column(elem_id = "col-container",scale=0.80):  
                extract_json_btn = gr.Button("Extract Meta data")
                extracted_json = gr.Textbox(label = "Meta data", lines=10)     

        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("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("Headings"):
            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("Extract Date"):
            with gr.Column(elem_id = "col-container",scale=0.80):  
                extract_date_btn = gr.Button("Extract date")
                extracted_date = gr.Textbox(label = "Extracted date", lines=10) 
 
                
    extractor  = Extractor() 
    upload_button.upload(file_output_fn,upload_button,file_output)
    summary_btn.click( extractor._refine_summary,[upload_button],summary)  

    pdftojson = PdftoJson()
    extract_json_btn.click(pdftojson.extract_text_from_pdf,upload_button,extracted_json)
                
    tags_btn.click(Tags.extract_tags,summary,tags)
    clauses_btn.click(Clauses.get_extracted_clauses,summary,clauses)
    
    ex= HeadingsExtractor()
    heading_btn.click(ex.extract_text,upload_button,heading)

    date =  ExtractDateAndDuration()
    extract_date_btn.click(date.itrate_each_page,upload_button,extracted_date)

demo.launch()