MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / tokenize

Function tokenize

nlp_class3/memory_network.py:40–46  ·  view source on GitHub ↗

Return the tokens of a sentence including punctuation. >>> tokenize('Bob dropped the apple. Where is the apple?') ['Bob', 'dropped', 'the', 'apple', '.', 'Where', 'is', 'the', 'apple', '?']

(sent)

Source from the content-addressed store, hash-verified

38
39
40def tokenize(sent):
41 '''Return the tokens of a sentence including punctuation.
42
43 >>> tokenize('Bob dropped the apple. Where is the apple?')
44 ['Bob', 'dropped', 'the', 'apple', '.', 'Where', 'is', 'the', 'apple', '?']
45 '''
46 return [x.strip() for x in re.split('(\W+?)', sent) if x.strip()]
47
48
49

Callers 1

get_storiesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected