Tanor commited on
Commit
b9e824a
·
1 Parent(s): 3717eda

ungraded inferface

Browse files
Files changed (1) hide show
  1. app.py +17 -3
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
- return pipe(text)
 
 
 
 
 
 
 
7
 
 
 
 
 
 
 
 
8
 
9
- iface = gr.Interface(fn=calculate, inputs="text", outputs="text")
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()