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)
| 201 | PUNCTUATION = ".,;:!?()[]{}`''\"@#$^&*+-|=~_" |
| 202 | |
| 203 | def 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 | |
| 214 | PORTER, LEMMA = "porter", "lemma" |
| 215 | def stem(word, stemmer=PORTER, **kwargs): |
no test coverage detected
searching dependent graphs…