MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / nopunctuation

Function nopunctuation

src/commoncode/text.py:56–64  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

54
55
56def 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
67CR = "\r"

Callers 1

python_safe_nameFunction · 0.85

Calls 2

nopuncFunction · 0.85
as_unicodeFunction · 0.70

Tested by

no test coverage detected