Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,17 +9,18 @@ model = AbsaModel.from_pretrained(
|
|
9 |
)
|
10 |
|
11 |
def analyze_text(text):
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
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="
|
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
|