robertselvam commited on
Commit
021aa42
1 Parent(s): 6537e7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +66 -73
app.py CHANGED
@@ -10,13 +10,8 @@ from incompletesentencefinder import IncompleteSentenceFinder
10
  from aggressive_content_finder import AggressiveContentFinder
11
  import gradio as gr
12
 
13
- overall_filepath = ''
14
  def file_output_fn(file_path):
15
  file_path = file_path.name
16
- global overall_filepath
17
- print("before",file_path)
18
- overall_filepath = file_path
19
- print("after",overall_filepath)
20
  return file_path
21
 
22
  #xiaobaiyuan/theme_land earneleh/paris
@@ -27,77 +22,75 @@ with gr.Blocks(css="style.css",theme='freddyaboulton/test-blue') as demo:
27
  Contract
28
  </h1>
29
  </center>""")
30
- with gr.Tabs():
31
- with gr.TabItem("Contract Summary"):
32
- with gr.Row(elem_id = "col-container",scale=0.80):
33
- with gr.Column(elem_id = "col-container",scale=0.80):
34
- file_output = gr.File(label="File Status",elem_classes="filenameshow")
35
-
36
- with gr.Column(elem_id = "col-container",scale=0.20):
37
- upload_button = gr.UploadButton(
38
- "Browse File",file_types=[".txt", ".pdf", ".doc", ".docx",".json",".csv"],
39
- elem_classes="uploadbutton")
40
- summary_btn = gr.Button("Get Summary",elem_classes="uploadbutton")
41
-
42
- with gr.Row(elem_id = "col-container",scale=0.60):
43
- summary = gr.Textbox(label = "Summary",lines=10)
44
-
45
- with gr.Row(elem_id = "col-container",scale=0.80):
46
- with gr.TabItem("Tags"):
47
- with gr.Column(elem_id = "col-container",scale=0.80):
48
- tags_btn = gr.Button("Tags Extracter")
49
- tags = gr.Textbox(label = "Tags", lines=10)
50
-
51
- with gr.TabItem("Key Values"):
52
- with gr.Column(elem_id = "col-container",scale=0.80):
53
- key_value_btn = gr.Button("Key Value Extractor")
54
- key_value = gr.Textbox(label = "Key Value",lines=10)
55
-
56
-
57
- with gr.TabItem("Clauses"):
58
- with gr.Column(elem_id = "col-container",scale=0.80):
59
- clauses_btn = gr.Button("Clauses Extractor")
60
- clauses = gr.Textbox(label = "Clauses", lines=10)
61
-
62
- with gr.TabItem("pdf"):
63
- with gr.Column(elem_id = "col-container",scale=0.80):
64
- heading_btn = gr.Button("Headings Extractor")
65
- heading = gr.Textbox(label = "Headings", lines=10)
66
-
67
- with gr.TabItem("Incorrect_Sentence"):
68
- with gr.Column(elem_id = "col-container",scale=0.80):
69
- incor_sen_btn = gr.Button("Incorrect Sentence Extractor")
70
- incorrect_sentence = gr.Textbox(label = "Incorrect Sentence", lines=10)
71
-
72
- with gr.TabItem("Incomplete Sentence"):
73
- with gr.Column(elem_id = "col-container",scale=0.80):
74
- incom_sen_btn = gr.Button("Incomplete Sentence Extractor")
75
- incomplete_sentence = gr.Textbox(label = "Incomplete Sentence", lines=10)
76
-
77
- with gr.TabItem("Aggressive Content"):
78
- with gr.Column(elem_id = "col-container",scale=0.80):
79
- aggres_sen_btn = gr.Button("Aggressive Content Extractor")
80
- aggressive_sentence = gr.Textbox(label = "Aggressive Content", lines=10)
81
-
82
- extractor = Extractor()
83
- upload_button.upload(file_output_fn,upload_button,file_output)
84
- summary_btn.click( extractor._refine_summary,[upload_button],summary)
85
 
86
-
87
- tags_btn.click(Tags.extract_tags,summary,tags)
88
- key_value_btn.click( KeyValue.extract_key_value_pair,summary,key_value)
89
- clauses_btn.click(Clauses.get_extracted_clauses,summary,clauses)
90
-
91
- ex= HeadingsExtractor()
92
- heading_btn.click(ex.extract_text,upload_button,heading)
93
 
94
- inf= IncorrectSentenceFinder()
95
- incor_sen_btn.click(inf.get_incorrect_sentence,upload_button,incorrect_sentence)
96
 
97
- inc= IncompleteSentenceFinder()
98
- incom_sen_btn.click(inc.get_incomplete_sentence,upload_button,incomplete_sentence)
99
 
100
- agg= AggressiveContentFinder()
101
- aggres_sen_btn.click(agg.get_aggressive_content,upload_button,aggressive_sentence)
102
 
103
  demo.launch(debug=True)
 
10
  from aggressive_content_finder import AggressiveContentFinder
11
  import gradio as gr
12
 
 
13
  def file_output_fn(file_path):
14
  file_path = file_path.name
 
 
 
 
15
  return file_path
16
 
17
  #xiaobaiyuan/theme_land earneleh/paris
 
22
  Contract
23
  </h1>
24
  </center>""")
25
+ with gr.Row(elem_id = "col-container",scale=0.80):
26
+ with gr.Column(elem_id = "col-container",scale=0.80):
27
+ file_output = gr.File(label="File Status",elem_classes="filenameshow")
28
+
29
+ with gr.Column(elem_id = "col-container",scale=0.20):
30
+ upload_button = gr.UploadButton(
31
+ "Browse File",file_types=[".txt", ".pdf", ".doc", ".docx",".json",".csv"],
32
+ elem_classes="uploadbutton")
33
+ summary_btn = gr.Button("Get Summary",elem_classes="uploadbutton")
34
+
35
+ with gr.Row(elem_id = "col-container",scale=0.60):
36
+ summary = gr.Textbox(label = "Summary",lines=10)
37
+
38
+ with gr.Row(elem_id = "col-container",scale=0.80):
39
+ with gr.TabItem("Tags"):
40
+ with gr.Column(elem_id = "col-container",scale=0.80):
41
+ tags_btn = gr.Button("Tags Extracter")
42
+ tags = gr.Textbox(label = "Tags", lines=10)
43
+
44
+ with gr.TabItem("Key Values"):
45
+ with gr.Column(elem_id = "col-container",scale=0.80):
46
+ key_value_btn = gr.Button("Key Value Extractor")
47
+ key_value = gr.Textbox(label = "Key Value",lines=10)
48
+
49
+
50
+ with gr.TabItem("Clauses"):
51
+ with gr.Column(elem_id = "col-container",scale=0.80):
52
+ clauses_btn = gr.Button("Clauses Extractor")
53
+ clauses = gr.Textbox(label = "Clauses", lines=10)
54
+
55
+ with gr.TabItem("pdf"):
56
+ with gr.Column(elem_id = "col-container",scale=0.80):
57
+ heading_btn = gr.Button("Headings Extractor")
58
+ heading = gr.Textbox(label = "Headings", lines=10)
59
+
60
+ with gr.TabItem("Incorrect_Sentence"):
61
+ with gr.Column(elem_id = "col-container",scale=0.80):
62
+ incor_sen_btn = gr.Button("Incorrect Sentence Extractor")
63
+ incorrect_sentence = gr.Textbox(label = "Incorrect Sentence", lines=10)
64
+
65
+ with gr.TabItem("Incomplete Sentence"):
66
+ with gr.Column(elem_id = "col-container",scale=0.80):
67
+ incom_sen_btn = gr.Button("Incomplete Sentence Extractor")
68
+ incomplete_sentence = gr.Textbox(label = "Incomplete Sentence", lines=10)
69
+
70
+ with gr.TabItem("Aggressive Content"):
71
+ with gr.Column(elem_id = "col-container",scale=0.80):
72
+ aggres_sen_btn = gr.Button("Aggressive Content Extractor")
73
+ aggressive_sentence = gr.Textbox(label = "Aggressive Content", lines=10)
74
+
75
+ extractor = Extractor()
76
+ upload_button.upload(file_output_fn,upload_button,file_output)
77
+ summary_btn.click( extractor._refine_summary,[upload_button],summary)
 
 
78
 
79
+
80
+ tags_btn.click(Tags.extract_tags,summary,tags)
81
+ key_value_btn.click( KeyValue.extract_key_value_pair,summary,key_value)
82
+ clauses_btn.click(Clauses.get_extracted_clauses,summary,clauses)
83
+
84
+ ex= HeadingsExtractor()
85
+ heading_btn.click(ex.extract_text,upload_button,heading)
86
 
87
+ inf= IncorrectSentenceFinder()
88
+ incor_sen_btn.click(inf.get_incorrect_sentence,upload_button,incorrect_sentence)
89
 
90
+ inc= IncompleteSentenceFinder()
91
+ incom_sen_btn.click(inc.get_incomplete_sentence,upload_button,incomplete_sentence)
92
 
93
+ agg= AggressiveContentFinder()
94
+ aggres_sen_btn.click(agg.get_aggressive_content,upload_button,aggressive_sentence)
95
 
96
  demo.launch(debug=True)