Closed brunoalano closed 7 years ago
datrie
does not do any special handling of whitespace characters. You specify ' '
as part of the alphabet therefore 'something nice'
is a valid word.
To get the desired behaviour remove ' '
from the alphabet and split each sentence manually before inserting it into the trie.
@superbobry Thanks, no problem.
This is how I done it:
for tk in [ ' '.join(title.split()[0:i]) for i in range(1, len(title.split())) ]:
if tk not in trie: trie[tk] = 0
I've a problem, for example:
But the
trie.prefixes
, should not return['something', 'something nice']
in this case? Should I split the Sentence by spaces, and create a record for each splitted word?