public List < String > getBioDictionaryMatch ( final String [ ] tokens ) { final List < String > entitiesList = new ArrayList < String > ( ) ; String prefix = "-" + BioCodec . START ; String gazEntry = null ; String searchSpan = null ; // iterative over tokens from the beginning for ( int i = 0 ; i < tokens . length ; i ++ ) { gazEntry = 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 ) ; gazEntry = lookup ( searchSpan . toLowerCase ( ) ) ; if ( gazEntry != null ) { break ; } } prefix = "-" + BioCodec . START ; // multi-token case if ( gazEntry != null ) { while ( i < j ) { entitiesList . add ( ( gazEntry + prefix ) . intern ( ) ) ; prefix = "-" + BioCodec . CONTINUE ; i ++ ; } } // one word case or last member of span if ( gazEntry != null ) { entitiesList . add ( ( gazEntry + prefix ) . intern ( ) ) ; } else { entitiesList . add ( BioCodec . OTHER ) ; } } return entitiesList ; }
Performs gazetteer match in a bio encoding .