The problem of tokenizer
https://github.com/google-research/bert/blob/35deae77e6b6c668cc8050853d16b4046193cbf0/tokenization.py#L249
The class WordpieceTokenizer show the case that
For example:
input = "unaffable"
output = ["un", "##aff", "##able"]
However when we use the greedy longest-match-first algorithm the input "unaffable" by the vocab.txt(from the official file uncased_L-12_H-768_A-12.zip),we actually get the output ["una","##ffa","##ble"]. I read the vocab.txt find that there is the vocab una which is longer than the vocab un.So,it leads to the problem which is different from our expectations. is it the given vocab problem or the defects of the algorithm?
Besides, the word ##aff is also not in the vocab.txt. now, I am curious about how to generate the vocab.txt?
It's just an example. The exact way that "unaffable" would actually be tokenized depends on the exact vocabulary. See this section about the vocabulary.
I know it.However,can I think that the given vocabulary is not good enough? we think that output ["un", "##aff", "##able"] is much better?
I think, there's still the problem.
My string was ,
tokenizer.tokenize("lighspots mood! keyhole thread bodysuit sleeved sparkly taupe heeled skirt!")
However, the vocab file contains the word "light" in given vocab.txt file, yet the output wa
['li', '##gh', '##sp', '##ots', 'mood', '!', 'key', '##hole', 'thread', 'body', '##suit', 'sleeve', '##d', 'spark', '##ly', 'tau', '##pe', 'heel', '##ed', 'skirt', '!']
why not, ['light', '##sp', '##ots', 'mood', '!', 'key', '##hole', 'thread', 'body', '##suit', 'sleeve', '##d', 'spark', '##ly', 'tau', '##pe', 'heel', '##ed', 'skirt', '!']
PS: However, this is a bit controversial, because in some case the shorter char words are what users want, so is the based on given first priority.