Skip to content

Instantly share code, notes, and snippets.

@skolo-online
Created January 9, 2022 06:43
Show Gist options
  • Save skolo-online/843fd7e219ed77885c20291fe6fe2599 to your computer and use it in GitHub Desktop.
Save skolo-online/843fd7e219ed77885c20291fe6fe2599 to your computer and use it in GitHub Desktop.
Tweet Classification App.py Route
@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