Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
def
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
pipe = pipeline("sentiment-analysis")
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
def aspects(sentense):
|
5 |
+
sentense=[sentense]
|
6 |
+
sentimentdata=sentiment(sentense)
|
7 |
+
fit_score=process.default_scorer(sentense,fit)
|
8 |
+
mat_score=process.default_scorer(sentense,material)
|
9 |
+
price_score=process.default_scorer(sentense,price)
|
10 |
+
sentimentlabel=sentimentdata[0].get("label")
|
11 |
+
sentprobability=sentimentdata[0].get("score")
|
12 |
+
return sentimentlabel,sentprobability,fit_score,price_score,mat_score
|
13 |
|
14 |
pipe = pipeline("sentiment-analysis")
|
15 |
+
interface=gr.Interface(fn=aspects,inputs=gr.inputs.Textbox(lines=10,placeholder="please insert your text"),
|
16 |
+
examples=[
|
17 |
+
["this product and not fitting well to my body and feel scratchy"],
|
18 |
+
["this fabric is super cool and feel very comfortable "]
|
19 |
+
|
20 |
+
],
|
21 |
+
title="Review Analyzer",
|
22 |
+
outputs=[gr.outputs.Textbox(type="auto", label="Sentiment"),
|
23 |
+
gr.outputs.Textbox(type="auto", label="Sentiment score"),
|
24 |
+
gr.outputs.Textbox(type="auto", label="Fit related score"),
|
25 |
+
gr.outputs.Textbox(type="auto", label="Price related score"),
|
26 |
+
gr.outputs.Textbox(type="auto", label="Material related score")],live=True)
|
27 |
+
interface.launch()
|