Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors/David_Elvis.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DAVID_ELVIS
10 changes: 6 additions & 4 deletions twitter_mining/twitter_mining.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
" def clean_tweets(self,twitter_text):\n",
"\n",
" #use pre processor\n",
" tweet = p.clean(twitter_text)\n",
" tweet = ppr.clean(twitter_text)\n",#the library pre processor was imported as ppr not p
"\n",
" #HappyEmoticons\n",
" emoticons_happy = set([\n",
Expand Down Expand Up @@ -193,7 +193,7 @@
" emoticons = emoticons_happy.union(emoticons_sad)\n",
"\n",
" stop_words = set(stopwords.words('english'))\n",
" word_tokens = word_tokenize(tweet)\n",
" word_tokens = word_tokenize(tweet)\n", #word_tokens was not imported from the nltk library
" #after tweepy preprocessing the colon symbol left remain after \n",
" #removing mentions\n",
" tweet = re.sub(r':', '', tweet)\n",
Expand Down Expand Up @@ -229,7 +229,7 @@
" \n",
"\n",
" #page attribute in tweepy.cursor and iteration\n",
" for page in tweepy.Cursor(api.search, q=keyword,count=200, include_rts=False):\n",
" for page in tweepy.Cursor(self.api.search, q=keyword,count=200, include_rts=False).pages():\n", #it is self.api.search not api.search and call the pages to iterate
"\n",
"\n",
" for status in page:\n",
Expand All @@ -253,6 +253,8 @@
" df.at[i, 'retweet_count'] = status['retweet_count']\n",
" continue\n",
"\n",
tweet_text = status['text'] # here first we should extract the tweet text and filter it by calling self.clean_tweets()
filtered_tweet = self.clean_tweets(tweet_text)
" #calculate sentiment\n",
" blob = TextBlob(filtered_tweet)\n",
" Sentiment = blob.sentiment \n",
Expand Down Expand Up @@ -327,7 +329,7 @@
"\n",
"#get data on keywords\n",
"ts = tweetsearch()\n",
"df = ts.get_tweets(covid_keywords, csvfile=tweets_file) #you saved the "
"df = ts.get_tweets(covid_keywords, csvfile=tweets_file) #the function was named as get_tweets and not get_data "
]
},
{
Expand Down