Created
January 9, 2022 06:43
-
-
Save skolo-online/843fd7e219ed77885c20291fe6fe2599 to your computer and use it in GitHub Desktop.
Tweet Classification App.py Route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/classify', methods=["GET", "POST"]) | |
def classify(): | |
query = 'Polokwane lang:en -is:retweet' | |
if request.method == 'POST': | |
query = '{} lang:en -is:retweet'.format(request.form['query']) | |
max_results = 20 | |
tweets = search.retrieveClasiffyTweets(query, max_results) | |
positiveTweets = [] | |
negativeTweets = [] | |
neutralTweets = [] | |
for tweet in tweets: | |
if tweet['classx'] == 'Positive': | |
positiveTweets.append(tweet) | |
if tweet['classx'] == 'Negative': | |
positiveTweets.append(tweet) | |
if tweet['classx'] == 'Neutral': | |
positiveTweets.append(tweet) | |
return render_template('class.html', **locals()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment