微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何修复属性“列表”

如何解决如何修复属性“列表”

我在处理 NLP 模型上的文本时遇到了一些疑问和问题。我不知道为什么会出现此错误:AttributeError: 'list' object has no attribute 'split. 下面是我的df['Text'].sample(5)

26278    [RT,@davidsirota:,subset,people,website,t...
63243    [RT,@jmartNYT:,The,presses,Team,Biden,As...
61059    [RT,@caitoz:,BREAKING:,nominate,"Li...
43160    [RT,@K_JeanPierre:,I,profoundly,honored,P...
Name: Text,dtype: object

下面是我的代码

def tokenizer(text):
    
    tokenized = [w for w in text.split() if w not in stopset]
    return tokenized
df['Text'] = df['Text'].apply(tokenizer)
def remove_emoji(string):
    emoji_pattern = re.compile("["
                           u"\U0001F600-\U0001F64F"  # emoticons
                           u"\U0001F300-\U0001F5FF"  # symbols & pictographs
                           u"\U0001F680-\U0001F6FF"  # transport & map symbols
                           u"\U0001F1E0-\U0001F1FF"  # flags (iOS)
                           u"\U00002702-\U000027B0"
                           u"\U000024C2-\U0001F251"
                           "]+",flags=re.UNICODE)
    return emoji_pattern.sub(r'',string)
def remove_nonwords(Text):
    if re.findall('\d',Text):
        return ''
    else:
        return Text
def clean_text(Text):
    text=' '.join([i for  i in Text.split() if i not in stopset])
    text=' '.join([stem.stem(word) for word in Text.split()])
    return Text
df['text2'] = df['Text'].apply(clean_text)

有人可以帮我吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。