pahri commited on
Commit
da3ea9f
·
verified ·
1 Parent(s): 3ae3bbe

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from setfit import AbsaModel
3
+
4
+ # Load the ABSA model
5
+ model = AbsaModel.from_pretrained(
6
+ "pahri/setfit-indo-restomix-aspect",
7
+ "pahri/setfit-indo-restomix-polarity",
8
+ spacy_model="id_core_news_trf",
9
+ )
10
+
11
+ def analyze_text(text):
12
+ """
13
+ Analyzes the input text using the ABSA model and returns aspects and sentiment.
14
+ Args:
15
+ text: The text to be analyzed.
16
+ Returns:
17
+ A formatted string containing aspects and sentiment.
18
+ """
19
+ pred = model.predict(text)
20
+ return pred
21
+
22
+ title = "Analisa Review Restoran Anda"
23
+ examples = [["Penyajiannya super aesthetic & instagramable.. Tempatnya juga keren, bikin betah & pengen foto-foto terus. Pelayanan ramah, parkir lumayan memadai. Recommended"]]
24
+
25
+ interface = gr.Interface(
26
+ fn=analyze_text,
27
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Masukkan review restoran Anda di sini..."),
28
+ outputs="text",
29
+ description=description,
30
+ title=title,
31
+ examples=examples,
32
+ layout="vertical" # Set the layout to vertical
33
+ )
34
+
35
+ interface.launch()