File size: 1,315 Bytes
c3fdb2a
8c5e1a4
 
6a2d61d
 
 
 
 
 
 
 
 
c3fdb2a
8c5e1a4
6a2d61d
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import gradio as gr
from transformers import pipeline
    
def aspects(sentense):
    sentense=[sentense]
    sentimentdata=sentiment(sentense)
    fit_score=process.default_scorer(sentense,fit)
    mat_score=process.default_scorer(sentense,material)
    price_score=process.default_scorer(sentense,price)
    sentimentlabel=sentimentdata[0].get("label")
    sentprobability=sentimentdata[0].get("score")    
    return  sentimentlabel,sentprobability,fit_score,price_score,mat_score

pipe = pipeline("sentiment-analysis")
interface=gr.Interface(fn=aspects,inputs=gr.inputs.Textbox(lines=10,placeholder="please insert your text"),
examples=[
          ["this product and not fitting well to my body and feel scratchy"],
        ["this fabric is super cool and feel very comfortable "]
       
    ],
    title="Review Analyzer",
                       outputs=[gr.outputs.Textbox(type="auto", label="Sentiment"),
                                gr.outputs.Textbox(type="auto", label="Sentiment score"),
                                gr.outputs.Textbox(type="auto", label="Fit related score"),
                                gr.outputs.Textbox(type="auto", label="Price related score"),
                                gr.outputs.Textbox(type="auto", label="Material related score")],live=True)
interface.launch()