tokens: If you have items that are sorted already you can make use of the bisect module ( or numpy has its own methods for working with sorted data ) :
ner_tags: O O O O O O O O O O O O O O B-Library O O O B-Library O O O O O O O O O O O