Spaces:
Sleeping
Sleeping
File size: 1,041 Bytes
2517c42 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import gradio as gr
from setfit import AbsaModel
# Load the ABSA model (assuming indo-setfit-absa-bert-base-restaurants is the aspect extraction model)
model = AbsaModel.from_pretrained(
"firqaaa/indo-setfit-absa-bert-base-restaurants-aspect",
"firqaaa/indo-setfit-absa-bert-base-restaurants-polarity",
spacy_model="id_core_news_trf",
)
def analyze_text(text):
"""
Analyzes the input text using the ABSA model and returns aspects and sentiment.
Args:
text: The text to be analyzed.
Returns:
A dictionary containing aspects and sentiment.
"""
aspects, sentiments = model.predict(text)
return {"Aspek": aspects, "Sentimen": sentiments}
description = "Analisa Aspek dan Sentimen Review Restoran"
title = "Analisa Review Restoran Anda"
examples = [["Makanannya enak, tapi pelayanannya lambat."]]
interface = gr.Interface(
fn=analyze_text,
inputs="textbox",
outputs="dict",
interpretation="text",
description=description,
title=title,
examples=examples
)
interface.launch() |