Update app.py
Browse files
app.py
CHANGED
@@ -100,7 +100,12 @@ def fls(text):
|
|
100 |
ner=pipeline('ner',model='Jean-Baptiste/camembert-ner-with-dates',tokenizer='Jean-Baptiste/camembert-ner-with-dates', aggregation_strategy="simple")
|
101 |
def fin_ner(text):
|
102 |
replaced_spans = ner(text)
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
|
106 |
#CUAD STARTS
|
@@ -116,7 +121,8 @@ def load_questions_short():
|
|
116 |
with open('questionshort.txt') as f:
|
117 |
questions_short = f.readlines()
|
118 |
return questions_short
|
119 |
-
|
|
|
120 |
def quad(query,file):
|
121 |
with open(file.name) as f:
|
122 |
paragraph = f.read()
|
@@ -150,7 +156,7 @@ def quad(query,file):
|
|
150 |
#iface = gr.Interface(fn=get_sustainability, inputs="textbox", title="CONBERT",description="SUSTAINABILITY TOOL", outputs=gr.HighlightedText(), allow_flagging="never")
|
151 |
#iface.launch()
|
152 |
|
153 |
-
iface = gr.Interface(fn=quad, inputs=[gr.
|
154 |
|
155 |
|
156 |
iface.launch()
|
|
|
100 |
ner=pipeline('ner',model='Jean-Baptiste/camembert-ner-with-dates',tokenizer='Jean-Baptiste/camembert-ner-with-dates', aggregation_strategy="simple")
|
101 |
def fin_ner(text):
|
102 |
replaced_spans = ner(text)
|
103 |
+
new_spans=[]
|
104 |
+
for item in replaced_spans:
|
105 |
+
item['entity']=item['entity_group']
|
106 |
+
del item['entity_group']
|
107 |
+
new_spans.append(item)
|
108 |
+
return {"text": text, "entities": new_spans}
|
109 |
|
110 |
|
111 |
#CUAD STARTS
|
|
|
121 |
with open('questionshort.txt') as f:
|
122 |
questions_short = f.readlines()
|
123 |
return questions_short
|
124 |
+
questions = load_questions()
|
125 |
+
questions_short = load_questions_short()
|
126 |
def quad(query,file):
|
127 |
with open(file.name) as f:
|
128 |
paragraph = f.read()
|
|
|
156 |
#iface = gr.Interface(fn=get_sustainability, inputs="textbox", title="CONBERT",description="SUSTAINABILITY TOOL", outputs=gr.HighlightedText(), allow_flagging="never")
|
157 |
#iface.launch()
|
158 |
|
159 |
+
iface = gr.Interface(fn=quad, inputs=[gr.Dropdown(choices=questions,label='SEARCH QUERY'),gr.inputs.File(label='TXT FILE')], title="CONBERT",description="SUSTAINABILITY 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")
|
160 |
|
161 |
|
162 |
iface.launch()
|