private boolean getsSupposedAbbreviation ( String text , int position ) { int ini ; boolean end = false ; String word = text ; // Indicates where the position of the supposed abbreviation begins for ( ini = position ; ini >= 0 ; ini -- ) if ( Character . isWhitespace ( text . charAt ( ini ) ) || isOpenBracket ( text . charAt ( ini ) ) ) break ; // Indicates where the supposed abbreviation should end for ( int i = position + 1 ; i < text . length ( ) - 1 && end == false ; i ++ ) { switch ( text . charAt ( i ) ) { // Possible end of the sentence or just part of the supposed // abbreviation case ' ' : if ( Character . isWhitespace ( text . charAt ( i + 1 ) ) || isEnding ( text . charAt ( i + 1 ) ) ) { word = word . substring ( ini + 1 , i + 1 ) ; end = true ; } break ; // Character that is part of the abbreviation default : break ; } } if ( end == true ) { if ( INITIALS . matcher ( word ) . find ( ) ) return true ; else if ( this . dic . contains ( new StringList ( word ) ) ) return true ; } return false ; }
Analyze a sentence and gets the word which contains the position of the error in the parameter and tells if it is an initial or if the abbreviation dictionary contains it or not .