File size: 1,323 Bytes
3f3ca03
f7ea213
 
 
 
 
3f3ca03
626e7c3
 
192a8bd
626e7c3
 
 
 
6e7a9e7
f7ea213
 
 
 
6e7a9e7
 
f7ea213
 
 
626e7c3
3f3ca03
 
06d0b3f
626e7c3
 
3f3ca03
f7ea213
 
 
6e7a9e7
 
 
 
 
 
 
 
 
 
 
 
 
 
4cc3a06
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
import gradio as gr
import torch
from score_fincat import score_fincat
from sus_fls import get_sustainability,fls
from Cuad_others import quad,summarize_text,fin_ner
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

def load_questions():
    questions = []
    with open('questionshort.txt') as f:
        questions = f.readlines()
    return questions
questions = load_questions()

answer_main=''     
def mainFun(query,file):
    text=''
    with open(file.name) as f:
        text = f.read()
    answer_main,answer_p=quad(query,file)
    return text,answer_p,summarize_text(answer_main)




demo = gr.Blocks()
with demo:
    txt_file = gr.File(label='CONTRACT')
    text = gr.Textbox(lines=10)
    selected_ques=gr.Dropdown(choices=questions,label='SEARCH QUERY')
    b1 = gr.Button("Analyze File")
    answer = gr.Textbox(lines=2)
    summarize = gr.Textbox(lines=2)
    b1.click(mainFun, inputs=[selected_ques,txt_file], outputs=[text,answer,summarize])
    
    b2=gr.Button("Get NER")
    label_ner = gr.Label()
    b1.click(fin_ner,inputs=answer_main,outputs=gr.HighlightedText())
    
    b3=gr.Button("Get CLAIM")
    label_claim = gr.Label()
    
    b4=gr.Button("Get SUSTAINABILITY")
    label_sus = gr.Label()
    
    b5=gr.Button("Get FLS")
    label_fls = gr.Label()
    
demo.launch()