|
|
|
"""demo.ipynb |
|
|
|
Automatically generated by Colab. |
|
|
|
Original file is located at |
|
https://colab.research.google.com/drive/19sodc0ANzqRgZ0VzMGXr4YQ3fvUvxyjv |
|
""" |
|
|
|
!pip install gradio --quiet |
|
!pip install transformers --quiet |
|
|
|
|
|
from transformers import pipeline |
|
|
|
sentiment_analysis = pipeline("text-classification", model="avichr/heBERT_sentiment_analysis") |
|
def analyze_sentiment(text): |
|
results = sentiment_analysis(text) |
|
for result in results: |
|
print(f"Label: {result['label']}, Score: {result['score']}") |
|
|
|
texts = [ |
|
"Worst rental I ever got" |
|
"I really enjoyed my stay !" |
|
|
|
] |
|
|
|
analyze_sentiment(texts) |
|
|
|
!pip install gradio |
|
|
|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
|
|
interface = gr.Interface( |
|
fn=analyze_sentiment, |
|
inputs=gr.Textbox(lines=2, placeholder="Enter your review or statement here..."), |
|
outputs=[ |
|
gr.Textbox(label="Sentiment"), |
|
gr.Number(label="Score") |
|
], |
|
title="Sentiment Analysis Score" |
|
) |
|
|
|
|
|
interface.launch() |