clean-text package?clean-text is a third-party package used to pre-process text data to obtain a normalized text representation.
The package can be installed via pip. Check the following command to install the clean-text package.
pip install clean-text
replace_punct() methodThe replace_punct() method replaces the punctuation in the given text with the replacement string.
replace_punct(text, replace_with=" ")
text: The text data.replace_with: The replacement string.The method returns the text data after replacing the punctuation.
import cleantextstring = "hello educative - 2-3-4 - hello edpresso!!"new_string = cleantext.replace_punct(string, replace_with=" ")print("Original String - '" + string + "'")print("Modified String - '" + new_string + "'")
cleantext package.replace_punct() method.