daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest May 16th, 2018 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
Top