File size: 2,165 Bytes
d704a2d b4079f4 d704a2d 0171406 d704a2d 0171406 d704a2d 0171406 d704a2d 0171406 d704a2d 0171406 4782ae8 4d2a553 0171406 6bbbbcd 0171406 ad33c4e 0171406 |
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 |
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)
def mainFun2(temp):
return fin_ner(temp.split('Probability:')[0])
def mainFun3(temp):
return score_fincat(temp.split('Probability:')[0])
def mainFun4(temp):
return get_sustainability(temp.split('Probability:')[0])
def mainFun5(temp):
return fls(temp.split('Probability:')[0])
demo = gr.Blocks()
with demo:
gr.Markdown("# **CONTRACT REVIEWING USING BERT(CONBERT)**")
gr.Markdown(
"""
BROWSE AND SELECT A CONTRACT/AGREEMENT IN TXT FORMAT
AND SELECT A QUESTION
""")
#FETCH AND DISPLAY CONTRACT
txt_file = gr.File(label='CONTRACT')
text = gr.Textbox(lines=10)
selected_ques=gr.Dropdown(choices=questions,value=questions[0],label='SEARCH QUERY')
b1 = gr.Button("Analyze File")
#DISPLAY ANSWER AND SUMMARIZATION
answer = gr.Textbox(lines=2)
summarize = gr.Textbox(lines=2)
b1.click(mainFun, inputs=[selected_ques,txt_file], outputs=[text,answer,summarize])
#DISPLAY NER
b2=gr.Button("Get NER")
label_ner = gr.HighlightedText()
b2.click(mainFun2,inputs=answer,outputs=label_ner)
#DISPLAY CLAIMS
b3=gr.Button("Get CLAIM")
label_claim = gr.HighlightedText()
b3.click(mainFun3,inputs=answer,outputs=label_claim)
#DISPLAY SUSTAINABILITY
b4=gr.Button("Get SUSTAINABILITY")
label_sus = gr.HighlightedText()
b4.click(mainFun4,inputs=answer,outputs=label_sus)
#DISPLAY FLS
b5=gr.Button("Get FLS")
label_fls = gr.HighlightedText()
b5.click(mainFun5,inputs=answer,outputs=label_fls)
demo.launch() |