MCPcopy Index your code
hub / github.com/clips/pattern / words

Function words

pattern/vector/__init__.py:203–212  ·  view source on GitHub ↗

Returns a list of words (alphanumeric character sequences) from the given string. Common punctuation marks are stripped from words.

(string, filter=lambda w: w.lstrip("'").isalnum(), punctuation=PUNCTUATION, **kwargs)

Source from the content-addressed store, hash-verified

201PUNCTUATION = ".,;:!?()[]{}`''\"@#$^&*+-|=~_"
202
203def words(string, filter=lambda w: w.lstrip("'").isalnum(), punctuation=PUNCTUATION, **kwargs):
204 """ Returns a list of words (alphanumeric character sequences) from the given string.
205 Common punctuation marks are stripped from words.
206 """
207 string = decode_utf8(string)
208 string = re.sub(r"([a-z|A-Z])'(m|s|ve|re|ll|d)", u"\\1 `'\\2", string)
209 words = (w.strip(punctuation).replace(u"`'", "'", 1) for w in string.split())
210 words = (w for w in words if filter is None or filter(w) is not False)
211 words = [w for w in words if w]
212 return words
213
214PORTER, LEMMA = "porter", "lemma"
215def stem(word, stemmer=PORTER, **kwargs):

Callers 1

__init__Method · 0.85

Calls 4

decode_utf8Function · 0.85
stripMethod · 0.80
filterFunction · 0.50
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…