print(clear_punctuation(‘“!!!test: remove full-stops, hashtags, symbols, commas, hyphen, semicolon etc from dataset using python for sentiment analysis?Commas, hyphen, semicolon, hash tags , punctuations are to be removed') )
# The aforementioned code removes most punctuation symbols. Nevertheless, if you want to remove specific items you may try the following:
string_punctuation = ".#,_;"
def remove_punctuation(s):
no_punct = ""
for letter in s:
if letter not in string_punctuation:
no_punct += letter
return no_punct
print(clear_punctuation('"test!!!remove full-stops, hashtags, symbols, commas, hyphen, semicolon etc from dataset using python for sentiment analysis?Commas, hyphen, semicolon, hash tags , punctuations are to be removed') )
print(clear_punctuation(‘“!!!test: remove full-stops, hashtags, symbols, commas, hyphen, semicolon etc from dataset using python for sentiment analysis?Commas, hyphen, semicolon, hash tags , punctuations are to be removed') )
# The aforementioned code removes most punctuation symbols. Nevertheless, if you want to remove specific items you may try the following:
string_punctuation = ".#,_;"
def remove_punctuation(s):
no_punct = ""
for letter in s:
if letter not in string_punctuation:
no_punct += letter
return no_punct
print(clear_punctuation('"test!!!remove full-stops, hashtags, symbols, commas, hyphen, semicolon etc from dataset using python for sentiment analysis?Commas, hyphen, semicolon, hash tags , punctuations are to be removed') )
I would use Regular Expressions for this task. I have used it for a very similar task in Java and it works quite well. A starting point to learn about this can be here: