private String extractContext(String s,int position){
  StringBuilder sb=new StringBuilder();
  int j=position - 1;
  char c=s.charAt(j);
  while (j > 0 && c != ' ' && c != '_') {
    c=s.charAt(--j);
  }
  String ps=j > 0 ? s.substring(j + 1,position) : s.substring(0,position);
  ps=convert(ps);
  sb.append("ps:");
  sb.append(ps);
  sb.append(" pw:");
  sb.append(lexicon.hasWord(ps) ? 1 : 0);
  j=position + 1;
  c=s.charAt(j);
  while (j < s.length() && c != ' ' && c != '_') {
    c=s.charAt(j++);
  }
  String ns=j < s.length() ? s.substring(position + 1,j - 1) : s.substring(position + 1);
  ns=convert(ns);
  sb.append(" ns:");
  sb.append(ns);
  sb.append(" nw:");
  sb.append(lexicon.hasWord(ns) ? 1 : 0);
  sb.append(" ps+ns:");
  sb.append(ps);
  sb.append('+');
  sb.append(ns);
  return sb.toString();
}

private String extractContext ( String s , int position ) { StringBuilder sb = new StringBuilder ( ) ; int j = position - 1 ; char c = s . charAt ( j ) ; while ( j > 0 && c != ' ' && c != '_' ) { c = s . charAt ( -- j ) ; } String ps = j > 0 ? s . substring ( j + 1 , position ) : s . substring ( 0 , position ) ; ps = convert ( ps ) ; sb . append ( "ps:" ) ; sb . append ( ps ) ; sb . append ( " pw:" ) ; sb . append ( lexicon . hasWord ( ps ) ? 1 : 0 ) ; j = position + 1 ; c = s . charAt ( j ) ; while ( j < s . length ( ) && c != ' ' && c != '_' ) { c = s . charAt ( j ++ ) ; } String ns = j < s . length ( ) ? s . substring ( position + 1 , j - 1 ) : s . substring ( position + 1 ) ; ns = convert ( ns ) ; sb . append ( " ns:" ) ; sb . append ( ns ) ; sb . append ( " nw:" ) ; sb . append ( lexicon . hasWord ( ns ) ? 1 : 0 ) ; sb . append ( " ps+ns:" ) ; sb . append ( ps ) ; sb . append ( '+' ) ; sb . append ( ns ) ; return sb . toString ( ) ; }
extracts a context string for each whitespace position .
