File size: 1,074 Bytes
da3ea9f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49efdc6
da3ea9f
 
 
49efdc6
 
da3ea9f
 
dfffd2c
da3ea9f
 
49efdc6
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
import gradio as gr
from setfit import AbsaModel

# Load the ABSA model
model = AbsaModel.from_pretrained(
    "pahri/setfit-indo-restomix-aspect",
    "pahri/setfit-indo-restomix-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 formatted string containing aspects and sentiment.
    """
    pred = model.predict(text)
    return pred

title = "Analisa Review Restoran Anda"
examples = [["Penyajiannya super aesthetic & instagramable.. Tempatnya juga keren, bikin betah & pengen foto-foto terus. Pelayanan ramah, parkir lumayan memadai. Recommended"]]
description = "Masukkan review restoran Anda untuk menganalisa aspek dan sentimen."

interface = gr.Interface(
    fn=analyze_text,
    inputs=gr.Textbox(lines=2, placeholder="Masukkan review restoran Anda di sini..."),
    outputs=gr.Text(),
    description=description,
    title=title,
    examples=examples
)

interface.launch()