public void scoreText ( String text , int factor , String ... keywords ) { if ( text != null && keywords != null ) { // Increment the score once for each keyword that is found within the text ... String lowercaseText = text . toLowerCase ( ) ; for ( String keyword : keywords ) { if ( keyword == null ) continue ; String lowercaseKeyword = keyword . toLowerCase ( ) ; int index = 0 ; while ( true ) { index = lowercaseText . indexOf ( lowercaseKeyword , index ) ; if ( index == - 1 ) break ; score += factor ; ++ index ; } } } }
Increment the score if the given text contains any of the supply keywords .