这是我在Google中使用的代码
import re
from textblob import TextBlob
import emoji
def clean_tweet(text):
text = re.sub(r'@[A-Za-z0-9]+', '', str(text)) # remove @mentions
text = re.sub(r'#', '', str(text)) # remove the '#' symbol
text = re.sub(r'RT[\s]+', '', str(text)) # remove RT
text = re.sub(r'https?\/\/S+', '', str(text)) # remove the hyperlink
text = re.sub(r'http\S+', '', str(text)) # remove the hyperlink
text = re.sub(r'www\S+', '', str(text)) # remove the www
text = re.sub(r'twitter+', '', str(text)) # remove the twitter
text = re.sub(r'pic+', '', str(text)) # remove the pic
text = re.sub(r'com', '', str(text)) # remove the com
return text
def remove_emoji(text):
return emoji.get_emoji_regexp().sub(u'', text)
当我打这些电话
tweets['cleaned_text']=tweets['text'].apply(clean_tweet)
tweets['cleaned_text']=tweets['cleaned_text'].apply(remove_emoji)
我得到了以下错误
AttributeError Traceback (most recent call last)
<ipython-input-20-9fe71f3cdb0c> in <module>
1 tweets['cleaned_text']=tweets['text'].apply(clean_tweet)
----> 2 tweets['cleaned_text']=tweets['cleaned_text'].apply(remove_emoji)
4 frames
<ipython-input-19-8c0d6ba00a5b> in remove_emoji(text)
24
25 def remove_emoji(text):
---> 26 return emoji.get_emoji_regexp().sub(u'', text)
AttributeError: module 'emoji' has no attribute 'get_emoji_regexp'
这很奇怪。我从来没有见过这个问题。有人能帮我吗?我在这里做错什么了吗?
发布于 2022-08-22 07:37:27
雷杰普‘ - get_emoji_regexp
方法被废弃,随后在包的新版本中被删除。
https://stackoverflow.com/questions/73441477
复制相似问题