Can someone help please, I am trying to extract some tweets and then perform some basic analysis. I am encountering an error and i suspect its around the below section of the code:
I defined a function called word_in_text(word, text). This function return True if a word is found in text, otherwise it returns False
def word_in_text(word, text):
word = word.lower()
text = [item.lower() for item in tweet]
match = re.search(word, text)
I get the following ERROR
File "*:\*\*\Anaconda3\lib\re.py", line 183, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object
Solved! Solved! Go to Solution.
Hi and welcome @BinTEPO ,
To match using the package that provides regular expressions, you must first craft a regular expression. Here are some handy tools:
After catching up on that and getting to know regular expressions you should be able to re-write the function to let it perform how you'd like to.
I know it's quite a bit to learn but it's pretty fun and if you're performing analysis on Tweets regular expressions will come in handy!
As always, just post back if you encounter any problems.