Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,7 +38,6 @@ def text_to_sentiment(text, all_score=False, label = True):
|
|
| 38 |
return fin_model(text, return_all_scores=all_score)
|
| 39 |
def fin_ext(text):
|
| 40 |
results = fin_model(split_in_sentences(text))
|
| 41 |
-
print(make_spans(text, results))
|
| 42 |
return make_spans(text, results)
|
| 43 |
def fin_ext_bis(text):
|
| 44 |
results = fin_model_bis(split_in_sentences(text))
|
|
@@ -402,6 +401,12 @@ color_map = {
|
|
| 402 |
"Negative": "red" # Red for negative
|
| 403 |
}
|
| 404 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
|
| 406 |
with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
|
| 407 |
with gr.Tab("Methodology"):
|
|
@@ -480,7 +485,7 @@ with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
|
|
| 480 |
analyze_btn1.click(fn=lambda p: process_paragraph_1_sent_tone(p), inputs=paragraph_1_dropdown, outputs=fin_spans_1)
|
| 481 |
|
| 482 |
analyze_btn1_ = gr.Button("With ProsusAI/finbert")
|
| 483 |
-
fin_spans_1_ = gr.HighlightedText(label="Financial Tone Analysis for PDF 1 (Bis)",color_map=
|
| 484 |
|
| 485 |
# Analyze financial tone using ProsusAI/finbert
|
| 486 |
analyze_btn1_.click(fn=lambda p: process_paragraph_1_sent_tone_bis(p), inputs=paragraph_1_dropdown, outputs=fin_spans_1_)
|
|
@@ -514,7 +519,7 @@ with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
|
|
| 514 |
analyze_btn2.click(fn=lambda p: process_paragraph_2_sent_tone(p), inputs=paragraph_2_dropdown, outputs=fin_spans_2)
|
| 515 |
|
| 516 |
analyze_btn2_ = gr.Button("With ProsusAI/finbert")
|
| 517 |
-
fin_spans_2_ = gr.HighlightedText(label="Financial Tone Analysis for PDF 2 (Bis)",color_map=
|
| 518 |
|
| 519 |
# Analyze financial tone using ProsusAI/finbert for PDF 2
|
| 520 |
analyze_btn2_.click(fn=lambda p: process_paragraph_2_sent_tone_bis(p), inputs=paragraph_2_dropdown, outputs=fin_spans_2_)
|
|
|
|
| 38 |
return fin_model(text, return_all_scores=all_score)
|
| 39 |
def fin_ext(text):
|
| 40 |
results = fin_model(split_in_sentences(text))
|
|
|
|
| 41 |
return make_spans(text, results)
|
| 42 |
def fin_ext_bis(text):
|
| 43 |
results = fin_model_bis(split_in_sentences(text))
|
|
|
|
| 401 |
"Negative": "red" # Red for negative
|
| 402 |
}
|
| 403 |
|
| 404 |
+
color_map1 = {
|
| 405 |
+
"positive": "green", # Green for positive
|
| 406 |
+
"neutral": "blue", # Blue for neutral
|
| 407 |
+
"negative": "red" # Red for negative
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
|
| 411 |
with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
|
| 412 |
with gr.Tab("Methodology"):
|
|
|
|
| 485 |
analyze_btn1.click(fn=lambda p: process_paragraph_1_sent_tone(p), inputs=paragraph_1_dropdown, outputs=fin_spans_1)
|
| 486 |
|
| 487 |
analyze_btn1_ = gr.Button("With ProsusAI/finbert")
|
| 488 |
+
fin_spans_1_ = gr.HighlightedText(label="Financial Tone Analysis for PDF 1 (Bis)",color_map=color_map1, show_legend=True)
|
| 489 |
|
| 490 |
# Analyze financial tone using ProsusAI/finbert
|
| 491 |
analyze_btn1_.click(fn=lambda p: process_paragraph_1_sent_tone_bis(p), inputs=paragraph_1_dropdown, outputs=fin_spans_1_)
|
|
|
|
| 519 |
analyze_btn2.click(fn=lambda p: process_paragraph_2_sent_tone(p), inputs=paragraph_2_dropdown, outputs=fin_spans_2)
|
| 520 |
|
| 521 |
analyze_btn2_ = gr.Button("With ProsusAI/finbert")
|
| 522 |
+
fin_spans_2_ = gr.HighlightedText(label="Financial Tone Analysis for PDF 2 (Bis)",color_map=color_map1, show_legend=True)
|
| 523 |
|
| 524 |
# Analyze financial tone using ProsusAI/finbert for PDF 2
|
| 525 |
analyze_btn2_.click(fn=lambda p: process_paragraph_2_sent_tone_bis(p), inputs=paragraph_2_dropdown, outputs=fin_spans_2_)
|