nl_tokens: Finds the start / end position of each item
pl_tokens: function findPositions ( data , items ) { var depth = 0 ; var rootId = - 1 ; var result = [ ] ; var currentItem = { } ; var accumulator = '' ; for ( var ci = 0 ; ci < data . length ; ci ++ ) { accumulator += data [ ci ] ; var matchedItem = false ; for ( var x = 0 ; x < items . length ; x ++ ) { var item = items [ x ] ; if ( depth > 0 && endsWith ( accumulator , item . end ) ) { depth -- ; if ( depth === 0 && rootId === x ) { currentItem . end = ci - item . end . length + 1 ; rootId = - 1 ; accumulator = '' ; result . push ( currentItem ) ; currentItem = { } ; } } else if ( endsWith ( accumulator , item . start ) ) { <mask> ++ ; if ( depth === 1 && rootId === - 1 ) { currentItem = { startChar : item . start , endChar : item . end , start : ci } ; rootId = x ; accumulator = '' ; } } } } return result ; }