It seems like there should be a simpler way than:
import string
s = "string. With. Punctuation?" # Sample string
out = s.translate(string.maketrans("",""), string.punctuation)
Is there?
It seems like there should be a simpler way than:
import string
s = "string. With. Punctuation?" # Sample string
out = s.translate(string.maketrans("",""), string.punctuation)
Is there?
Remove stop words from the text file using Python
Regular expressions are simple enough, if you know them.
I like to use a function like this:
I haven't seen this answer yet. Just use a regex; it removes all characters besides word characters (
\w
) and number characters (\d
), followed by a whitespace character (\s
):