private int getTokenCount ( String article ) { Pattern notWhiteSpace = Pattern . compile ( "\\S+" ) ; Matcher matcher = notWhiteSpace . matcher ( article ) ; int tokens = 0 ; while ( matcher . find ( ) ) tokens ++ ; return tokens ; }
Returns the number of tokens in the article .