Giter VIP home page Giter VIP logo

git-get-started's People

Contributors

10acad avatar abdulazeez001 avatar ada-k avatar aineathesecond avatar amiinubello avatar arniebarniejr avatar ataraxia-m avatar ayebilla avatar comsavvy avatar davidelvis avatar emelda-hub avatar gideonbusayo avatar haddyadnan avatar jabor047 avatar karenngugi avatar kenmbelenzi avatar kiiru-anastasia avatar kodevick avatar kwambiee avatar lawalogunfowora avatar memoire21 avatar munyolec avatar mwi-kali avatar patrick5455 avatar photon12 avatar stephyi avatar temilad avatar virgoaugustine avatar yabebalfantaye avatar yehualashetgit avatar

Stargazers

 avatar  avatar

Watchers

 avatar

git-get-started's Issues

clean_tweets defined but not used

The clean_tweets function should be used to clean the tweets.
Capture

Change and add as below:

#calculate sentiment
filtered_tweet =self.clean_tweets(status['text'])
blob = TextBlob(filtered_tweet)
Sentiment = blob.sentiment
polarity = Sentiment.polarity
subjectivity = Sentiment.subjectivity

Name error

107 
108         #page attribute in tweepy.cursor and iteration
109         for page in tweepy.Cursor(api.search, q=keyword,count=200, include_rts=False):

name api is not defined.

we can fix it by editing to self.api.search

api is not defined

To resolve this issue will have to add this line api = tweepy.API(auth) before using the api.search

Filtered_tweet variable

The filtered_tweet variable (in Line 134) in the get_tweet function in the tweet_search class has been called but was defined in the clean_tweets function i.e it has not been defined in the get_tweet function.

Edit

Failed to import csv and re modules

'Cursor' object is not iterable

Error 'cursor' object is not iterable occurs on the following line:
for page in tweepy.Cursor(self.api.search, q=keyword,count=200, include_rts=False):
so we add .pages() to go through all the pages or .pages() to go through required number of pages.

for page in tweepy.Cursor(self.api.search, q=keyword,count=200, include_rts=False).pages():

Class not working

Class not working due to the following reasons:

the "self" key word was not defined in init method

It does not have "get_data()" method but "get_tweets()"

the "data/ethiopia_covid19_23june2020.json" does not exist in the directory but "covid19_23june2020.json"

A cvs file was parsed instead of json file

import & references Issues identified

Inconsistent use of variable names

The variable name given to the preprocessor library imported is consistent. ppr was used from the start and p was used to call method clean

import preprocessor as ppr
#use preprocessor
>> tweet = p.clean(twitter_text)

use of library regex without initial import

Regex was used to compile regex patterns but was never imported

We have to do an import re

Calling an unavailable class method on a class object

The method get_data in ts.get_data is not available in the class tweetsearch

df = ts.get_data(covid_keywords, csvfile=tweets_file)
It appears the intended method to be called is get_tweets.
hence we ought to have:

df = ts.get_tweets(covid_keywords, csvfile=tweets_file)

Missing modules.

Some modules have either not been imported or their aliases do not match what is in the code.

Examples

  • preprocessor: aliased as ppr during import but referenced as p in the tweetSearch() class
  • string import missing.

Wrong Instance

get_tweets should be called in place of get_data which was used in the code as nothing like get_data exists in the class

tweetfile name variable was changed

filename in the tweetfile variable as the name was not consistent
with the filename sent to us on the slack channel

tweetfile variable used ethiopia/........ but the filename didnt contain the word ethiopia

Class Error

No self parameter passed into tweet search in def_init function for the tweets_search class.

Stream data and save it to file

In class tweetsearch(), the api can not be read by the function get_tweets().
Saved numbers of tweets from availed data was 1000.

Installing Tweepy

tweepy

The snippet above gives errors; No module called ''tweepy'
The code should specify the essence of the commented pip installations

TypeError: 'Cursor' object is not iterable

This was fixed by adding .page() to this line of code
#page attribute in tweepy.cursor and iteration
for page in tweepy.Cursor(self.api.search,q=keyword,count=200, include_rts=False).pages():

Error in defined function def get_tweets()

The def get_tweets(self,keyword,csvfile=None) utilizes the api.search.
which culminates to the line below in the twitter_mining code:
#page attribute in tweepy.cursor and iteration for page in tweepy.Cursor(api.search, q=keyword,count=200, include_rts=False):

The correct reference is stated below:
#page attribute in tweepy.cursor and iteration for page in tweepy.Cursor(self.api.search, q=keyword,count=200, include_rts=False):

Reading the json file

When using the pandas read_json to read in the json file:

Incorrect syntax:

if not csvfile is None:
#If the file exists, then read the existing data from the CSV file.
if os.path.exists(csvfile):
df = pd.read_json('covid19_23june2020.json')

the code above will give the trailing data error, you can simply add lines = True as shown below

Correct syntax:

if not csvfile is None:
#If the file exists, then read the existing data from the CSV file.
if os.path.exists(csvfile):
df = pd.read_json('covid19_23june2020.json', lines=True)

Cursor Object

The cursor object is used to loop through data.
Therefore we append .pages() to the end of the line since we are looping through pages.

Installing other library

Not found:
!pip install textblob
!pip install preprocessor

aside: !pip install tweepy which was already given

image

Missing files

Hi,
When I try to run the Stream part of the Code, I find an error which is" No such file or directory". And I am having issues on adding the json file path.

Error resolve

After debugging the code, some crucial part that can be solve, I corrected them immediately but by running the code I keep on getting ValueError: Only unicode objects are escapable. Got None of type <class 'NoneType'>.
By: [email protected]
error_code

Twitter Mining errors

  1. Constructor function for class tweetsearch does not instantiate with self
  2. tweetsearch has no method get_data replace with get_tweets
  3. replace for page in tweepy.Cursor(api.search, q=keyword,count=200, include_rts=False): with for page in tweepy.Cursor(self. api.search, q=keyword,count=200, include_rts=False).pages():
  4. change tweet = p.clean(twitter_text) to tweet = ppr.clean(twitter_text)
  5. change clean_tweets to @staticmethod since it does not require the instance of the class
  6. fixed filtered words by adding clean_text = status['text'] filtered_tweet= self.clean_tweets(clean_text)
  7. Import missing libraries import re #regular expression
    nltk.download('punkt')
    from nltk.tokenize import word_tokenize
  8. Add twitter credentials to StdOutListener

'cursor' object is not iterable

107 
108         #page attribute in tweepy.cursor and iteration
109         for page in tweepy.Cursor(self.api.search, q=keyword,count=200, include_rts=False):

line 109 raised the error and it can be fixed with
for page in tweepy.Cursor(self.api.search, q=keyword,count=200, include_rts=False).pages():

Code errors

  1. In class tweetsearch, function init(), there's no 'self' keyword.
  2. In class tweetsearch, function clean_tweets(), a typo occured when using import 'ppr'.
  3. In class tweetsearch, package for 're' is used but has not been imported, line 85
  4. In class tweetsearch, function clean_tweets(), package 'word_tokenize' is used but has no import, line 98
  5. In function clean_tweets(), method string has been used but has not been imported, line 119
  6. Function get_tweets(), there is unresolved reference to 'api.search', line 132
  7. Function get_tweets(), there is unresolved reference to variable 'filtered_tweet',

Line of code in get_tweets() method missing self

This particular line of code in the get_tweets(self,keyword,csvfile=None) references the use of api.search.
It says:

#page attribute in tweepy.cursor and iteration for page in tweepy.Cursor(api.search, q=keyword,count=200, include_rts=False):
But it should be
#page attribute in tweepy.cursor and iteration for page in tweepy.Cursor(self.api.search, q=keyword,count=200, include_rts=False):

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.