File size: 974 Bytes
f7ff258 cfb044a f7ff258 cfb044a f7ff258 |
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# -*- coding: utf-8 -*-
"""demo.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/19sodc0ANzqRgZ0VzMGXr4YQ3fvUvxyjv
"""
# Use a pipeline as a high-level helper
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)
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() |