pahri commited on
Commit
9a77699
1 Parent(s): e4bd936

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -9,17 +9,18 @@ model = AbsaModel.from_pretrained(
9
  )
10
 
11
  def analyze_text(text):
12
- """
13
- Analyzes the input text using the ABSA model and returns aspects and sentiment.
14
-
15
- Args:
16
- text: The text to be analyzed.
17
-
18
- Returns:
19
- A dictionary containing aspects and sentiment.
20
- """
21
- aspects, sentiments = model.predict(text)
22
- return {"Aspek": aspects, "Sentimen": sentiments}
 
23
 
24
  description = "Analisa Aspek dan Sentimen Review Restoran"
25
  title = "Analisa Review Restoran Anda"
@@ -28,7 +29,7 @@ examples = [["Makanannya enak, tapi pelayanannya lambat."]]
28
  interface = gr.Interface(
29
  fn=analyze_text,
30
  inputs="textbox",
31
- outputs="dict",
32
  description=description,
33
  title=title,
34
  examples=examples
 
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
+ aspects, sentiments = model.predict(text)
20
+ result = "Aspek:\n"
21
+ for aspect, sentiment in zip(aspects, sentiments):
22
+ result += f"- {aspect}: {sentiment}\n"
23
+ return result
24
 
25
  description = "Analisa Aspek dan Sentimen Review Restoran"
26
  title = "Analisa Review Restoran Anda"
 
29
  interface = gr.Interface(
30
  fn=analyze_text,
31
  inputs="textbox",
32
+ outputs="text",
33
  description=description,
34
  title=title,
35
  examples=examples