File size: 756 Bytes
8df1c7e
e8be44f
41c9c41
e8be44f
 
dac9003
e8be44f
dac9003
e8be44f
dac9003
e8be44f
 
41c9c41
8df1c7e
 
41c9c41
8df1c7e
e8be44f
 
 
 
 
 
 
 
 
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
import streamlit as st
from transformers import pipeline

st.title("Sentiment Analysis And Translation App")
text = st.text_input("Enter a sentence:")

sentiment_analyzer = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")

translation = pipeline("translation_en_to_ar", model="anibahug/marian-finetuned-kde4-en-to-ar")

if text:
    results = sentiment_analyzer(text)
    
    sentiment = results[0]['label']
    confidence = results[0]['score']
    
    st.write(f"Sentiment: {sentiment}")
    st.write(f"Confidence: {confidence:.2f}")

# if text:
#     result = sentiment_analysis(text)
#     st.json(result)

if text:
    result = translation(text)[0]
    st.write(f"Translated text: {result['translation_text']}")