Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 有没有办法清除这些奇怪的符号 def_clean(文本): text=text.lower() text=re.sub(r'RT | RT','',text) text=re.sub(r'&;','&',text) text=re.sub(r'[?!.;:,#@-],'',text) text=re.sub(r“[$&+,:;=?#]|[0-9]| |“,”,text) text=re.sub(“,”,text) text=re.sub(r'https?|::\/\w.*','',text) text=re.sub(r'\/?w*','',text) text=re.sub(r'\ã°–*','',text) words=text.split() words=[w代表w,如果w不在stopwords中] text=”“.join(单词) text=emoji_pattern.sub(r'',text) 返回文本_Python_Twitter_Nlp - Fatal编程技术网

Python 有没有办法清除这些奇怪的符号 def_clean(文本): text=text.lower() text=re.sub(r'RT | RT','',text) text=re.sub(r'&;','&',text) text=re.sub(r'[?!.;:,#@-],'',text) text=re.sub(r“[$&+,:;=?#]|[0-9]| |“,”,text) text=re.sub(“,”,text) text=re.sub(r'https?|::\/\w.*','',text) text=re.sub(r'\/?w*','',text) text=re.sub(r'\ã°–*','',text) words=text.split() words=[w代表w,如果w不在stopwords中] text=”“.join(单词) text=emoji_pattern.sub(r'',text) 返回文本

Python 有没有办法清除这些奇怪的符号 def_clean(文本): text=text.lower() text=re.sub(r'RT | RT','',text) text=re.sub(r'&;','&',text) text=re.sub(r'[?!.;:,#@-],'',text) text=re.sub(r“[$&+,:;=?#]|[0-9]| |“,”,text) text=re.sub(“,”,text) text=re.sub(r'https?|::\/\w.*','',text) text=re.sub(r'\/?w*','',text) text=re.sub(r'\ã°–*','',text) words=text.split() words=[w代表w,如果w不在stopwords中] text=”“.join(单词) text=emoji_pattern.sub(r'',text) 返回文本,python,twitter,nlp,Python,Twitter,Nlp,到目前为止,我已经使用了上面的代码。我不知道如何清理这个 上周五晚上快乐(tgif)上周五晚上tgif法尔法 可以使用以下正则表达式删除所有非ASCII字符: text=re.sub(r'[^\x00-\x7F]+','',text) 另见这个问题: def _clean(text): text = text.lower() text = re.sub(r'RT|rt', '', text) text = re.sub(r'&', '&', t

到目前为止,我已经使用了上面的代码。我不知道如何清理这个

上周五晚上快乐(tgif)上周五晚上tgif法尔法


可以使用以下正则表达式删除所有非ASCII字符:

text=re.sub(r'[^\x00-\x7F]+','',text)
另见这个问题:

 def _clean(text):
    text = text.lower()
    text = re.sub(r'RT|rt', '', text)
    text = re.sub(r'&', '&', text)
    text = re.sub(r'[?!.;:,#@-]', '', text)
    text = re.sub(r"[$&+,:;=?#]|[0-9]|<ed>|<U\+[A-Z0-9]+>", "", text)
    text = re.sub("<+[A-Z0-9]+>", "", text)
    text = re.sub(r'https?|:\//\w.*', '', text)
    text = re.sub(r'\//?w*', '',text)
    text = re.sub(r'\ ã°â*', '' ,text)
    words = text.split()
    words = [w for w in words if w not in stopwords]
    text = " ".join(words)
    text = emoji_pattern.sub(r'', text)
    return text