Spaces:
Runtime error
Runtime error
File size: 768 Bytes
68330f9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import streamlit as st
from flair.models import TextClassifier
from flair.data import Sentence
import numpy as np
global tagger
def load_flair():
return TextClassifier.load('en-sentiment')
def main():
tagger = load_flair()
st.markdown("<h1 style = 'textalign:center; color:blue;'> Sentiment Detection </h1>", unsafe_allow_html = True)
st.write("Sentiment Detection from text is a classical problem. This is used when you try to predict the sentiment of comments.")
input_sent = st.text_input("Input Sentence", "Although not well rated, the food in this restaurant was tasty and I enjoyed the meal!")
s = Sentence(input_sent)
tagger.predict(s)
st.write("### Your Sentence is ", str(s.labels))
if __name__ == '__main__':
main()
|