Spaces:
Running
on
Zero
Running
on
Zero
pentarosarium
commited on
Commit
•
0d417b5
1
Parent(s):
a5ea954
v.1.49
Browse files
app.py
CHANGED
@@ -96,6 +96,12 @@ class EventDetector:
|
|
96 |
device=device
|
97 |
)
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
# Initialize sentiment models
|
100 |
self.finbert = pipeline(
|
101 |
"sentiment-analysis",
|
@@ -271,22 +277,22 @@ class EventDetector:
|
|
271 |
impact = "Неопределенный эффект"
|
272 |
reasoning = ""
|
273 |
|
274 |
-
# If sentiment is negative, estimate impact
|
275 |
if sentiment == "Negative":
|
|
|
276 |
impact, reasoning = self.estimate_impact(translated_text, entity)
|
|
|
277 |
|
278 |
# Detect events
|
279 |
event_type, event_summary = self.detect_events(text, entity)
|
280 |
|
281 |
#translate Reasoning back
|
282 |
-
|
283 |
-
reasoning_ru = self._translate_text(reasoning)
|
284 |
-
|
285 |
return {
|
286 |
'translated_text': translated_text,
|
287 |
'sentiment': sentiment,
|
288 |
'impact': impact,
|
289 |
-
'reasoning':
|
290 |
'event_type': event_type,
|
291 |
'event_summary': event_summary
|
292 |
}
|
@@ -652,7 +658,7 @@ def create_interface():
|
|
652 |
# Create state for file data
|
653 |
current_file = gr.State(None)
|
654 |
|
655 |
-
gr.Markdown("# AI-анализ мониторинга новостей v.1.
|
656 |
|
657 |
with gr.Row():
|
658 |
file_input = gr.File(
|
|
|
96 |
device=device
|
97 |
)
|
98 |
|
99 |
+
self.rutranslator = pipeline(
|
100 |
+
"translation",
|
101 |
+
model="Helsinki-NLP/opus-mt-en-ru",
|
102 |
+
device=device
|
103 |
+
)
|
104 |
+
|
105 |
# Initialize sentiment models
|
106 |
self.finbert = pipeline(
|
107 |
"sentiment-analysis",
|
|
|
277 |
impact = "Неопределенный эффект"
|
278 |
reasoning = ""
|
279 |
|
280 |
+
# If sentiment is negative, estimate impact and produce impact reasoning translated back into russian
|
281 |
if sentiment == "Negative":
|
282 |
+
|
283 |
impact, reasoning = self.estimate_impact(translated_text, entity)
|
284 |
+
reasoning = self.rutranslator(reasoning)[0]['translation_text']
|
285 |
|
286 |
# Detect events
|
287 |
event_type, event_summary = self.detect_events(text, entity)
|
288 |
|
289 |
#translate Reasoning back
|
290 |
+
|
|
|
|
|
291 |
return {
|
292 |
'translated_text': translated_text,
|
293 |
'sentiment': sentiment,
|
294 |
'impact': impact,
|
295 |
+
'reasoning': reasoning,
|
296 |
'event_type': event_type,
|
297 |
'event_summary': event_summary
|
298 |
}
|
|
|
658 |
# Create state for file data
|
659 |
current_file = gr.State(None)
|
660 |
|
661 |
+
gr.Markdown("# AI-анализ мониторинга новостей v.1.49")
|
662 |
|
663 |
with gr.Row():
|
664 |
file_input = gr.File(
|