blazingbunny commited on
Commit
a52c03c
·
verified ·
1 Parent(s): a488001

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 google.cloud import language_v1
3
+
4
+ def print_result(annotations):
5
+ # ... (same as your existing function)
6
+
7
+ def analyze_sentiment(texts): # Modify for text input (texts will be a string)
8
+ client = language_v1.LanguageServiceClient()
9
+ document = language_v1.Document(content=texts, type_=language_v1.Document.Type.PLAIN_TEXT)
10
+ annotations = client.analyze_sentiment(request={"document": document})
11
+ return annotations
12
+
13
+ st.title("Sentiment Analysis App")
14
+ st.write("Enter some text to analyze its sentiment:")
15
+
16
+ text_input = st.text_area("Text to analyze", height=200)
17
+
18
+ if st.button("Analyze Sentiment"):
19
+ if text_input:
20
+ annotations = analyze_sentiment(text_input)
21
+ print_result(annotations)
22
+ else:
23
+ st.warning("Please enter some text.")