public String stemString(String str){
  StringBuffer result=new StringBuffer();
  int start=-1;
  for (int j=0; j < str.length(); j++) {
    char c=str.charAt(j);
    if (Character.isLetterOrDigit(c)) {
      if (start == -1) {
        start=j;
      }
    }
 else     if (c == '\'') {
      if (start == -1) {
        result.append(c);
      }
    }
 else {
      if (start != -1) {
        result.append(stem(str.substring(start,j)));
        start=-1;
      }
      result.append(c);
    }
  }
  if (start != -1) {
    result.append(stem(str.substring(start,str.length())));
  }
  return result.toString();
}

public String stemString ( String str ) { StringBuffer result = new StringBuffer ( ) ; int start = - 1 ; for ( int j = 0 ; j < str . length ( ) ; j ++ ) { char c = str . charAt ( j ) ; if ( Character . isLetterOrDigit ( c ) ) { if ( start == - 1 ) { start = j ; } } else if ( c == '\'' ) { if ( start == - 1 ) { result . append ( c ) ; } } else { if ( start != - 1 ) { result . append ( stem ( str . substring ( start , j ) ) ) ; start = - 1 ; } result . append ( c ) ; } } if ( start != - 1 ) { result . append ( stem ( str . substring ( start , str . length ( ) ) ) ) ; } return result . toString ( ) ; }
stems everything in the given string . string is converted to lower case before stemming .
