daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest May 16th, 2018 101 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top