vishnu23 commited on
Commit
68330f9
·
1 Parent(s): 86d2c38

Create app.py

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