|
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") |
|
|
|
|
|
|
|
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() |