Spaces:
Running
Running
Commit ·
38c5f49
1
Parent(s): 94c8f6d
back to finberts non-lazy
Browse files
app.py
CHANGED
|
@@ -36,21 +36,6 @@ import plotly.graph_objects as go
|
|
| 36 |
from datetime import datetime
|
| 37 |
import plotly.express as px
|
| 38 |
|
| 39 |
-
def get_finbert():
|
| 40 |
-
if "finbert" not in st.session_state:
|
| 41 |
-
st.session_state.finbert = pipeline("sentiment-analysis", model="ProsusAI/finbert")
|
| 42 |
-
return st.session_state.finbert
|
| 43 |
-
|
| 44 |
-
def get_roberta():
|
| 45 |
-
if "roberta" not in st.session_state:
|
| 46 |
-
st.session_state.roberta = pipeline("sentiment-analysis", model="cardiffnlp/twitter-roberta-base-sentiment")
|
| 47 |
-
return st.session_state.roberta
|
| 48 |
-
|
| 49 |
-
def get_finbert_tone():
|
| 50 |
-
if "finbert_tone" not in st.session_state:
|
| 51 |
-
st.session_state.finbert_tone = pipeline("sentiment-analysis", model="yiyanghkust/finbert-tone")
|
| 52 |
-
return st.session_state.finbert_tone
|
| 53 |
-
|
| 54 |
|
| 55 |
class ProcessControl:
|
| 56 |
def __init__(self):
|
|
@@ -1167,9 +1152,9 @@ def display_sentiment_results(row, sentiment, impact=None, reasoning=None):
|
|
| 1167 |
|
| 1168 |
|
| 1169 |
# Initialize sentiment analyzers
|
| 1170 |
-
|
| 1171 |
-
|
| 1172 |
-
|
| 1173 |
|
| 1174 |
|
| 1175 |
def get_mapped_sentiment(result):
|
|
@@ -1185,13 +1170,13 @@ def get_mapped_sentiment(result):
|
|
| 1185 |
def analyze_sentiment(text):
|
| 1186 |
try:
|
| 1187 |
finbert_result = get_mapped_sentiment(
|
| 1188 |
-
|
| 1189 |
)
|
| 1190 |
roberta_result = get_mapped_sentiment(
|
| 1191 |
-
|
| 1192 |
)
|
| 1193 |
finbert_tone_result = get_mapped_sentiment(
|
| 1194 |
-
|
| 1195 |
)
|
| 1196 |
|
| 1197 |
# Count occurrences of each sentiment
|
|
@@ -1547,7 +1532,7 @@ def main():
|
|
| 1547 |
st.set_page_config(layout="wide")
|
| 1548 |
|
| 1549 |
with st.sidebar:
|
| 1550 |
-
st.title("::: AI-анализ мониторинга новостей (v.4.
|
| 1551 |
st.subheader("по материалам СКАН-ИНТЕРФАКС")
|
| 1552 |
|
| 1553 |
model_choice = st.radio(
|
|
|
|
| 36 |
from datetime import datetime
|
| 37 |
import plotly.express as px
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
class ProcessControl:
|
| 41 |
def __init__(self):
|
|
|
|
| 1152 |
|
| 1153 |
|
| 1154 |
# Initialize sentiment analyzers
|
| 1155 |
+
finbert = pipeline("sentiment-analysis", model="ProsusAI/finbert")
|
| 1156 |
+
roberta = pipeline("sentiment-analysis", model="cardiffnlp/twitter-roberta-base-sentiment")
|
| 1157 |
+
finbert_tone = pipeline("sentiment-analysis", model="yiyanghkust/finbert-tone")
|
| 1158 |
|
| 1159 |
|
| 1160 |
def get_mapped_sentiment(result):
|
|
|
|
| 1170 |
def analyze_sentiment(text):
|
| 1171 |
try:
|
| 1172 |
finbert_result = get_mapped_sentiment(
|
| 1173 |
+
finbert(text, truncation=True, max_length=512)[0]
|
| 1174 |
)
|
| 1175 |
roberta_result = get_mapped_sentiment(
|
| 1176 |
+
roberta(text, truncation=True, max_length=512)[0]
|
| 1177 |
)
|
| 1178 |
finbert_tone_result = get_mapped_sentiment(
|
| 1179 |
+
finbert_tone(text, truncation=True, max_length=512)[0]
|
| 1180 |
)
|
| 1181 |
|
| 1182 |
# Count occurrences of each sentiment
|
|
|
|
| 1532 |
st.set_page_config(layout="wide")
|
| 1533 |
|
| 1534 |
with st.sidebar:
|
| 1535 |
+
st.title("::: AI-анализ мониторинга новостей (v.4.18):::")
|
| 1536 |
st.subheader("по материалам СКАН-ИНТЕРФАКС")
|
| 1537 |
|
| 1538 |
model_choice = st.radio(
|