File size: 930 Bytes
34473f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b923f75
34473f3
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from .services import SentimentAnalyzer
from functools import lru_cache

# @st.cache(allow_output_mutation=False, hash_funcs={Tokenizer: str})
@lru_cache(maxsize=1)
def load_text_generator():
    predictor = SentimentAnalyzer()
    return predictor


predictor = load_text_generator()


def write():
    st.markdown(
        """
        # Arabic Sentiment Analysis

        """
    )
    
    input_text = st.text_input(
        "Enter your text here:",
    )
    if st.button("Predict"):
        with st.spinner("Predicting..."):
            prediction, score, all_score = predictor.predict([input_text])
            st.write(f"Result: {prediction[0]}")
            detailed_score = {
                "Positive": all_score[0][0],
                "Neutral": all_score[0][1],
                "Negative": all_score[0][2],
            }
            st.write("All scores:")
            st.write(detailed_score)