Guest User

Untitled

a guest
May 16th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. def tokenize(phrase):
  2. """
  3. Split phrase words into a parts (tokens).
  4. The result can be useful for autocomplete purpose.
  5.  
  6. Example:
  7. hello world => h,he,hel,hell,hello,w,wo,wor,worl,world
  8. """
  9. a = []
  10. for word in phrase.split():
  11. for i in range(len(word)):
  12. a.append(word[0:i + 1])
  13. return a
Add Comment
Please, Sign In to add comment