public List < String > getBilouDictionaryMatch ( final String [ ] tokens ) { final List < String > entitiesList = new ArrayList < String > ( ) ; String prefix = "-" + BilouCodec . START ; String gazClass = null ; String searchSpan = null ; // iterative over tokens from the beginning for ( int i = 0 ; i < tokens . length ; i ++ ) { gazClass = null ; int j ; // iterate over tokens from the end for ( j = tokens . length - 1 ; j >= i ; j -- ) { // create span for search in dictionary Map; the first search takes as // span // the whole sentence searchSpan = createSpan ( tokens , i , j ) ; gazClass = lookup ( searchSpan . toLowerCase ( ) ) ; if ( gazClass != null ) { break ; } } prefix = "-" + BilouCodec . START ; // multi-token case if ( gazClass != null ) { while ( i < j ) { entitiesList . add ( ( gazClass + prefix ) . intern ( ) ) ; prefix = "-" + BilouCodec . CONTINUE ; i ++ ; } } // one word case or last member of span if ( gazClass != null ) { if ( prefix . equals ( "-" + BilouCodec . START ) ) { entitiesList . add ( ( gazClass + "-" + BilouCodec . UNIT ) . intern ( ) ) ; } else if ( prefix . equals ( "-" + BilouCodec . CONTINUE ) ) { entitiesList . add ( ( gazClass + "-" + BilouCodec . LAST ) . intern ( ) ) ; } } else { entitiesList . add ( BilouCodec . OTHER ) ; } } return entitiesList ; }
Performs gazetteer match in a bilou encoding .