Reputation: 33
import re
def preprocessor(text):
text = re.sub('<[^>]*>', '', text)
emoticons = re.findall('(?::|;|=)(?:-)?(?:\)|\(|D|P)', text)
text = re.sub('[\W]+', ' ', text.lower()) + \'.join(emoticons).replace('-', '')
return text
I am getting an error in line 5 saying "unexpected character after line continuation character". Please, somebody help me out.
Upvotes: 1
Views: 727
Reputation: 21274
Your join()
statement is not properly formed. Because you have a bare \
, the interpreter thinks you're invoking the line continuation character, e.g.:
print("a \
b")
# a b
If you want to join on \
, use:
print("\\".join(['a','b']))
# a\b
In your case:
'\\'.join(emoticons)
Upvotes: 3