Tanor's picture
Update app.py
add1320
raw
history blame contribute delete
No virus
2.32 kB
import gradio as gr
from sentiwordnet_calculator import SentimentPipeline
pipe = SentimentPipeline("Tanor/SRGPTSENTPOS0", "Tanor/SRGPTSENTNEG0")
def calculate(text):
result = pipe(text)
# Visual representation
visual = result
# Numerical representation
numerical = {key: round(value, 2) for key, value in result.items()}
# Create a formatted string
numerical_str = ", ".join(f"{key}: {value}" for key, value in numerical.items())
return visual, numerical_str
iface = gr.Interface(
fn=calculate,
inputs=gr.inputs.Textbox(lines=5, placeholder="Enter your text here..."),
outputs=[gr.outputs.Label(num_top_classes=3), "text"],
title="Sentiment Analysis for Serbian",
description="""
Ovaj alat vrši analizu sentimenta na uneseni tekst koristeći model obučen na definicijama srpskog rečnika.
Model je prvobitno bio prethodno obučen na <a href='https://huggingface.co/JeRTeh/sr-gpt2-large' target='_blank'>sr-gpt2-large modelu Mihaila Škorića</a>,
a potom je bio usavršen na odabranim definicijama iz srpskog WordNeta. Molimo vas da ograničite unos na 300 tokena.
Izlazi predstavljaju pozitivne (POS), negativne (NEG) i objektivne (OBJ) ocene sentimenta.
This tool performs sentiment analysis on the input text using a model trained on Serbian dictionary definitions.
The model was initially pretrained on the <a href='https://huggingface.co/JeRTeh/sr-gpt2-large' target='_blank'>sr-gpt2-large model by Mihailo Škorić</a>,
then fine-tuned on selected definitions from the Serbian WordNet. Please limit the input to 300 tokens.
The outputs represent the Positive (POS), Negative (NEG), and Objective (OBJ) sentiment scores.
""",
examples=[
["osoba koja ne prihvata nove ideje"],
["intenzivna ojađenost"],
["uopštenih osećanja tuge"],
["žalostan zbog gubitka ili uskraćenosti"],
["činjenje dobra; osećaj dobrotvornosti"],
["Jako pozitivno osećanje poštovanja i privrežen..."],
["usrećiti ili zadovoljiti"],
["Korisna ili vredna osobina"],
["uzrokovati strah"],
["svojstvo onoga kome nedostaje živost"],
["koji čini živahnim i veselim"],
["Biti zdrav, osećati se dobro."],
]
)
iface.launch()