def find_words(string, trie):
 _boundary_re = re.compile(('[%s]+' % re.escape(DEFAULT_BOUNDARY_CHARS)))
 results = []
 start = 0
 while (start < len(string)):
  keys = match_all(string[start:], trie)
  for key in keys:
   l = len(key)
   if (((start + l) == len(string)) or _boundary_re.match(string[(start + l)])):
    results.append((key, start, (start + l)))
  m = _boundary_re.search(string, start)
  if (m is None):
   break
  start = m.end()
 return results

def find_words ( string , trie ) : _boundary_re = re . compile ( ( '[%s]+' % re . escape ( DEFAULT_BOUNDARY_CHARS ) ) ) results = [ ] start = 0 while ( start < len ( string ) ) : keys = match_all ( string [ start : ] , trie ) for key in keys : l = len ( key ) if ( ( ( start + l ) == len ( string ) ) or _boundary_re . match ( string [ ( start + l ) ] ) ) : results . append ( ( key , start , ( start + l ) ) ) m = _boundary_re . search ( string , start ) if ( m is None ) : break start = m . end ( ) return results
find_words -> list of tuples find all the keys in the trie that match full words in the string .