Replace any non alphanum symbol (i.e. punctuation) in text with space. Preserve the characters offsets by replacing punctuation with spaces. Warning: this also drops line endings.
(text)
| 54 | |
| 55 | |
| 56 | def nopunctuation(text): |
| 57 | """ |
| 58 | Replace any non alphanum symbol (i.e. punctuation) in text with space. |
| 59 | Preserve the characters offsets by replacing punctuation with spaces. |
| 60 | Warning: this also drops line endings. |
| 61 | """ |
| 62 | if not isinstance(text, str): |
| 63 | text = as_unicode(text) |
| 64 | return re.sub(nopunc(), " ", text) |
| 65 | |
| 66 | |
| 67 | CR = "\r" |
no test coverage detected