MCPcopy Index your code
hub / github.com/ddbourgin/numpy-ml / tokenize_chars

Function tokenize_chars

numpy_ml/preprocessing/nlp.py:151–159  ·  view source on GitHub ↗

Split a string into individual characters, optionally removing punctuation and stop-words in the process.

(line, lowercase=True, filter_punctuation=True, **kwargs)

Source from the content-addressed store, hash-verified

149
150
151def tokenize_chars(line, lowercase=True, filter_punctuation=True, **kwargs):
152 """
153 Split a string into individual characters, optionally removing punctuation
154 and stop-words in the process.
155 """
156 line = line.lower() if lowercase else line
157 line = strip_punctuation(line) if filter_punctuation else line
158 chars = list(re.sub(" {2,}", " ", line).strip())
159 return chars
160
161
162def remove_stop_words(words):

Callers

nothing calls this directly

Calls 1

strip_punctuationFunction · 0.85

Tested by

no test coverage detected