Shredder commited on
Commit
55caca8
1 Parent(s): 7c39280

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -37,22 +37,22 @@ def get_sustainability(text):
37
  return highlight
38
  #SUSTAINABILITY ENDS
39
 
40
- ##Summarization
 
41
  def summarize_text(text):
42
- summarizer = pipeline("summarization", model="knkarthick/MEETING_SUMMARY")
43
  resp = summarizer(text)
44
  stext = resp[0]['summary_text']
45
  return stext
46
 
47
  ##Forward Looking Statement
 
48
  def fls(text):
49
- fls_model = pipeline("text-classification", model="yiyanghkust/finbert-fls", tokenizer="yiyanghkust/finbert-fls")
50
  results = fls_model(split_in_sentences(text))
51
  return make_spans(text,results)
52
 
53
  ##Company Extraction
 
54
  def fin_ner(text):
55
- ner=pipeline('ner',model='Jean-Baptiste/camembert-ner-with-dates',tokenizer='Jean-Baptiste/camembert-ner-with-dates', aggregation_strategy="simple")
56
  replaced_spans = ner(text)
57
  return replaced_spans
58
 
@@ -89,10 +89,12 @@ def quad(query,file):
89
  raw_answer=data['0'][i]['text']
90
  answer += f"Answer {i+1}: {data['0'][i]['text']} -- \n"
91
  answer += f"Probability: {round(data['0'][i]['probability']*100,1)}%\n\n"
92
- summarizer = pipeline("summarization", model="knkarthick/MEETING_SUMMARY")
93
- resp = summarizer(answer)
94
- stext = resp[0]['summary_text']
95
- return stext,answer
 
 
96
 
97
 
98
  # b6 = gr.Button("Get Sustainability")
@@ -102,5 +104,7 @@ def quad(query,file):
102
  #iface = gr.Interface(fn=get_sustainability, inputs="textbox", title="CONBERT",description="SUSTAINABILITY TOOL", outputs=gr.HighlightedText(), allow_flagging="never")
103
  #iface.launch()
104
 
105
- iface = gr.Interface(fn=quad, inputs=[gr.inputs.Textbox(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')], allow_flagging="never")
 
 
106
  iface.launch()
 
37
  return highlight
38
  #SUSTAINABILITY ENDS
39
 
40
+ ##Summarization
41
+ summarizer = pipeline("summarization", model="knkarthick/MEETING_SUMMARY")
42
  def summarize_text(text):
 
43
  resp = summarizer(text)
44
  stext = resp[0]['summary_text']
45
  return stext
46
 
47
  ##Forward Looking Statement
48
+ fls_model = pipeline("text-classification", model="yiyanghkust/finbert-fls", tokenizer="yiyanghkust/finbert-fls")
49
  def fls(text):
 
50
  results = fls_model(split_in_sentences(text))
51
  return make_spans(text,results)
52
 
53
  ##Company Extraction
54
+ ner=pipeline('ner',model='Jean-Baptiste/camembert-ner-with-dates',tokenizer='Jean-Baptiste/camembert-ner-with-dates', aggregation_strategy="simple")
55
  def fin_ner(text):
 
56
  replaced_spans = ner(text)
57
  return replaced_spans
58
 
 
89
  raw_answer=data['0'][i]['text']
90
  answer += f"Answer {i+1}: {data['0'][i]['text']} -- \n"
91
  answer += f"Probability: {round(data['0'][i]['probability']*100,1)}%\n\n"
92
+ #summarizer = pipeline("summarization", model="knkarthick/MEETING_SUMMARY")
93
+ #resp = summarizer(answer)
94
+ #stext = resp[0]['summary_text']
95
+
96
+
97
+ return answer,summarize_text(answer),fin_ner(answer),get_sustainability(answer),fls(answer)
98
 
99
 
100
  # b6 = gr.Button("Get Sustainability")
 
104
  #iface = gr.Interface(fn=get_sustainability, inputs="textbox", title="CONBERT",description="SUSTAINABILITY TOOL", outputs=gr.HighlightedText(), allow_flagging="never")
105
  #iface.launch()
106
 
107
+ iface = gr.Interface(fn=quad, inputs=[gr.inputs.Textbox(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='SUSTAINABILITY'),gr.HighlightedText(label='FLS')], allow_flagging="never")
108
+
109
+
110
  iface.launch()