File size: 1,253 Bytes
10f176f
 
 
 
 
 
 
 
4b31fb8
1330102
b6cb8b5
10f176f
 
 
 
 
 
 
 
 
 
 
4b31fb8
b6cb8b5
 
 
10f176f
 
35d43f7
10f176f
 
 
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
from predict import run_prediction
from io import StringIO
import json
import gradio as gr
import spacy
from spacy import displacy
import torch
import nltk
from score_fincat import score_fincat
from sus_fls import get_sustainability,fls
from Cuad_others import quad,summarize_text,fin_ner
nltk.download('punkt')
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

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

def mainFun(query,file):
    answer,answer_p=quad(query,file.name)
    return answer_p,summarize_text(answer),fin_ner(answer),score_fincat(answer),get_sustainability(answer),fls(answer)
                
                   
iface = gr.Interface(fn=mainFun, inputs=[gr.Dropdown(choices=questions,label='SEARCH QUERY'),gr.inputs.File(label='TXT FILE')], title="CONBERT",description="CONTRACT REVIEW TOOL",article='Article', outputs=[gr.outputs.Textbox(label='Answer'),gr.outputs.Textbox(label='Summary'),gr.HighlightedText(label='NER'),gr.HighlightedText(label='CLAIM'),gr.HighlightedText(label='SUSTAINABILITY'),gr.HighlightedText(label='FLS')], allow_flagging="never")


iface.launch()