pakkinlau commited on
Commit
85e0481
·
1 Parent(s): 7615b51

adding initial files

Browse files
Files changed (3) hide show
  1. Dockerfile +8 -0
  2. app.py +29 -0
  3. requirements.txt +2 -0
Dockerfile ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ FROM huggingface/transformers-pytorch-cpu
2
+
3
+ WORKDIR /app
4
+ COPY . /app
5
+
6
+ RUN pip install -r requirements.txt
7
+
8
+ CMD ["streamlit", "run", "app.py"]
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from textblob import TextBlob
3
+
4
+ # Function to perform sentiment analysis
5
+ def analyze_sentiment(text):
6
+ analysis = TextBlob(text)
7
+ if analysis.sentiment.polarity > 0:
8
+ return 'Positive'
9
+ elif analysis.sentiment.polarity == 0:
10
+ return 'Neutral'
11
+ else:
12
+ return 'Negative'
13
+
14
+ # Streamlit app
15
+ def main():
16
+ st.title("Document Sentiment Analysis")
17
+
18
+ # File uploader
19
+ uploaded_file = st.file_uploader("Choose a text file", type="txt")
20
+
21
+ if uploaded_file is not None:
22
+ # To read file as string:
23
+ text = str(uploaded_file.read(), "utf-8")
24
+ st.write("Analyzing Sentiment...")
25
+ sentiment = analyze_sentiment(text)
26
+ st.write(f"The overall sentiment of the document is: {sentiment}")
27
+
28
+ if __name__ == "__main__":
29
+ main()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ textblob