Adding forward looking statements
Browse files
app.py
CHANGED
@@ -59,6 +59,26 @@ def fin_ext(text):
|
|
59 |
print (fin_spans)
|
60 |
return fin_spans
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
demo = gr.Blocks()
|
63 |
|
64 |
demo = gr.Blocks()
|
@@ -89,5 +109,9 @@ with demo:
|
|
89 |
b5 = gr.Button("Extract Financial Sentiment")
|
90 |
fin_spans = gr.HighlightedText()
|
91 |
b5.click(fin_ext, inputs=text, outputs=fin_spans)
|
|
|
|
|
|
|
|
|
92 |
|
93 |
demo.launch()
|
|
|
59 |
print (fin_spans)
|
60 |
return fin_spans
|
61 |
|
62 |
+
##Forward Looking Statement
|
63 |
+
def fls(text):
|
64 |
+
print ("sent")
|
65 |
+
doc = nlp(text)
|
66 |
+
doc_sents = [sent for sent in doc.sents]
|
67 |
+
sents_list = []
|
68 |
+
for sent in doc.sents:
|
69 |
+
sents_list.append(sent.text)
|
70 |
+
fin_model = pipeline("text-classification", model="yiyanghkust/finbert-fls", tokenizer="yiyanghkust/finbert-fls")
|
71 |
+
results = fin_model(sents_list)
|
72 |
+
print (results)
|
73 |
+
results_list = []
|
74 |
+
for i in range(len(results)):
|
75 |
+
results_list.append(results[i]['label'])
|
76 |
+
fls_spans = []
|
77 |
+
fls_spans = list(zip(sents_list,results_list))
|
78 |
+
print (fls_spans)
|
79 |
+
return fls_spans
|
80 |
+
|
81 |
+
|
82 |
demo = gr.Blocks()
|
83 |
|
84 |
demo = gr.Blocks()
|
|
|
109 |
b5 = gr.Button("Extract Financial Sentiment")
|
110 |
fin_spans = gr.HighlightedText()
|
111 |
b5.click(fin_ext, inputs=text, outputs=fin_spans)
|
112 |
+
with gr.Row():
|
113 |
+
b6 = gr.Button("Extract Forward Looking Statements")
|
114 |
+
fin_spans = gr.HighlightedText()
|
115 |
+
b6.click(fls, inputs=text, outputs=fls_spans)
|
116 |
|
117 |
demo.launch()
|