├── .gitattributes
├── Building a Sentiment Analysys Flask App using nltk.png
├── LICENSE
├── README.md
├── app.py
├── requirements.txt
├── static
└── style.css
└── templates
└── form.html
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.csv filter=lfs diff=lfs merge=lfs -text
2 |
--------------------------------------------------------------------------------
/Building a Sentiment Analysys Flask App using nltk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/J-Mourad/Flask-Sentiment-Analysis-App/5a5e0c372b88c2bdeace3d840b654a4dfea11129/Building a Sentiment Analysys Flask App using nltk.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Packt
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Flask-Sentiment-Analysis-App
2 | Flask Sentiment Analysis Application
3 |
4 | [](https://youtu.be/Zj5QPRZEoTk)
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, request, render_template
2 | from sklearn.feature_extraction.text import TfidfVectorizer
3 | from sklearn.metrics.pairwise import cosine_similarity
4 | from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
5 | from nltk.corpus import stopwords
6 |
7 | nltk.download('stopwords')
8 |
9 | set(stopwords.words('english'))
10 | app = Flask(__name__)
11 |
12 | @app.route('/')
13 | def my_form():
14 | return render_template('form.html')
15 |
16 | @app.route('/', methods=['POST'])
17 | def my_form_post():
18 | stop_words = stopwords.words('english')
19 | text1 = request.form['text1'].lower()
20 |
21 | processed_doc1 = ' '.join([word for word in text1.split() if word not in stop_words])
22 |
23 | sa = SentimentIntensityAnalyzer()
24 | dd = sa.polarity_scores(text=processed_doc1)
25 | compound = round((1 + dd['compound'])/2, 2)
26 |
27 | return render_template('form.html', final=compound, text1=text1)
28 |
29 | if __name__ == "__main__":
30 | app.run(debug=True, host="127.0.0.1", port=5002, threaded=True)
31 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | flask
2 | nltk
3 | requests
4 | scikit-learn
5 | vadersentiment
6 |
--------------------------------------------------------------------------------
/static/style.css:
--------------------------------------------------------------------------------
1 | html {
2 | background: #404550;
3 | }
4 |
5 | body {
6 | font: 100% Arial, Helvetica, sans-serif;
7 | line-height: 1.5;
8 | position: relative;
9 | background: #fff;
10 | color: rgb(76, 67, 65);
11 | font-weight:normal;
12 | font-style:normal;
13 |
14 | width: 1280px;
15 | margin: 20 auto;
16 | padding: 20px;
17 | }
18 |
19 |
20 | form, div{
21 | border-bottom: 2px solid rgb(76, 67, 65);
22 | margin-bottom: 5em;
23 | margin-left: auto;
24 | margin-right: auto;
25 | width: 50em
26 | }
27 |
28 | h1 {
29 | font-family: Georgia, Times, "Times New Roman", serif;
30 | font-size: 1.8em;
31 | border-bottom: 2px solid rgb(76, 67, 65);
32 | margin-bottom: 1.5em;
33 | background: url(../_images/icon_sprites_50.png) no-repeat
34 | }
35 |
36 | .example_a {
37 | border: none;
38 | background: #404040;
39 | color: #ffffff !important;
40 | font-weight: 100;
41 | padding: 20px;
42 | text-transform: uppercase;
43 | border-radius: 6px;
44 | display: inline-block;
45 | transition: all 0.3s ease 0s;
46 |
47 | float: right;
48 | margin-top: 2em;
49 | }
50 |
51 | .example_a:hover {
52 | color: #404040 !important;
53 | font-weight: 700 !important;
54 | letter-spacing: 3px;
55 | background: none;
56 | -webkit-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
57 | -moz-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
58 | transition: all 0.3s ease 0s;
59 | }
--------------------------------------------------------------------------------
/templates/form.html:
--------------------------------------------------------------------------------
1 |
2 |