我想删除主题标签符号 ( '#') 和分隔单词 ( '_') 的下划线
例子: "this tweet is example #key1_key2_key3"
我想要的结果: "this tweet is example key1 key2 key3"
我的代码使用字符串:
#Remove punctuation , # Hashtag Symbol
translate_table = dict((ord(char), None) for char in string.punctuation)
cleaned_combined_tweets.translate(translate_table)
Run Code Online (Sandbox Code Playgroud)
这给出了结果: "this tweet is example key1key2key3"
我正在使用阿拉伯语文本,我想删除阿拉伯语标点符号示例:
s="????? ??????? ?? ??? ??????? ! ?????? ???????? ? ,? ?? .???????"
Run Code Online (Sandbox Code Playgroud)
我希望输出" ? ? "也被删除,因为当我使用时:
import string
tr= str.maketrans("","", string.punctuation)
Run Code Online (Sandbox Code Playgroud)
输出是 '????? ??????? ?? ??? ??????? ?????? ???????? ? ?? ???????'