Spaces:
Build error
Build error
Commit ·
01d2765
1
Parent(s): ac7706a
Upload 2 files
Browse files
app.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pyabsa import available_checkpoints
|
| 2 |
+
import warnings
|
| 3 |
+
warnings.simplefilter("ignore")
|
| 4 |
+
checkpoint_map = available_checkpoints('atepc', show_ckpts=False)
|
| 5 |
+
from pyabsa import ATEPCCheckpointManager
|
| 6 |
+
aspect_extractor = ATEPCCheckpointManager.get_aspect_extractor(checkpoint='english',
|
| 7 |
+
auto_device=True # False means load model on CPU
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
import gradio as gr
|
| 11 |
+
import pandas as pd
|
| 12 |
+
def inference(text):
|
| 13 |
+
result = aspect_extractor.extract_aspect(inference_source=[text],
|
| 14 |
+
pred_sentiment=True)
|
| 15 |
+
|
| 16 |
+
result = pd.DataFrame({
|
| 17 |
+
'aspect': result[0]['aspect'],
|
| 18 |
+
'sentiment': result[0]['sentiment']
|
| 19 |
+
})
|
| 20 |
+
|
| 21 |
+
return result
|
| 22 |
+
|
| 23 |
+
if __name__ == '__main__':
|
| 24 |
+
iface = gr.Interface(
|
| 25 |
+
fn=inference,
|
| 26 |
+
inputs=["text"],
|
| 27 |
+
examples=[['The wine list is incredible and extensive and diverse , the food is all incredible and the staff was all very nice ,'
|
| 28 |
+
' good at their jobs and cultured .'],
|
| 29 |
+
['Though the menu includes some unorthodox offerings (a peanut butter roll, for instance), the classics are pure and '
|
| 30 |
+
'great--we have never had better sushi anywhere, including Japan.'],
|
| 31 |
+
['Everything, from the soft bread, soggy salad, and 50 minute wait time, with an incredibly rude service to deliver'
|
| 32 |
+
' below average food .'],
|
| 33 |
+
['Even though it is running Snow Leopard, 2.4 GHz C2D is a bit of an antiquated CPU and thus the occasional spinning '
|
| 34 |
+
'wheel would appear when running Office Mac applications such as Word or Excel .'],
|
| 35 |
+
['Good Work user'],
|
| 36 |
+
['camera is good, battery drains fast'],
|
| 37 |
+
],
|
| 38 |
+
outputs="dataframe",
|
| 39 |
+
description="Project by Devansh Mistry with PyABSA Library",
|
| 40 |
+
title='ASPECT BASED SEMANTICS ANALYTICS'
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
iface.launch()
|