Spaces:
Runtime error
Runtime error
ungraded inferface
Browse files
app.py
CHANGED
@@ -1,10 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
from sentiwordnet_calculator import SentimentPipeline
|
|
|
3 |
pipe = SentimentPipeline("Tanor/SRGPTSENTPOS2", "Tanor/SRGPTSENTNEG2")
|
4 |
|
5 |
def calculate(text):
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
iface
|
10 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from sentiwordnet_calculator import SentimentPipeline
|
3 |
+
|
4 |
pipe = SentimentPipeline("Tanor/SRGPTSENTPOS2", "Tanor/SRGPTSENTNEG2")
|
5 |
|
6 |
def calculate(text):
|
7 |
+
result = pipe(text)
|
8 |
+
# Visual representation
|
9 |
+
visual = result
|
10 |
+
# Numerical representation
|
11 |
+
numerical = {key: round(value, 2) for key, value in result.items()}
|
12 |
+
# Create a formatted string
|
13 |
+
numerical_str = ", ".join(f"{key}: {value}" for key, value in numerical.items())
|
14 |
+
return visual, numerical_str
|
15 |
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=calculate,
|
18 |
+
inputs=gr.inputs.Textbox(lines=5, placeholder="Enter your text here..."),
|
19 |
+
outputs=[gr.outputs.Label(num_top_classes=3), "text"],
|
20 |
+
title="Sentiment Analysis",
|
21 |
+
description="This tool performs sentiment analysis on the input text using a model trained on Serbian dictionary definitions. Please limit the input to 300 tokens. The outputs represent the Positive (POS), Negative (NEG), and Objective (OBJ) sentiment scores."
|
22 |
+
)
|
23 |
|
24 |
+
iface.launch()
|
|