public void addWords(String phrase){
  if (phrase.equals("#") || phrase.equals(""))   return;
  String[] words=spliterator(phrase);
  if (words.length < 2)   return;
  for (int i=0; i < words.length; i++) {
    if (i == 0) {
      Vector<String> startWords=chain.get("_start");
      startWords.add(words[i]);
      Vector<String> suffix=chain.get(words[i]);
      if (suffix == null) {
        suffix=new Vector<>();
        suffix.add(words[i + 1]);
        chain.put(words[i],suffix);
      }
    }
 else     if (i == words.length - 1) {
      Vector<String> endWords=chain.get("_end");
      endWords.add(words[i]);
    }
 else {
      Vector<String> suffix=chain.get(words[i]);
      if (suffix == null) {
        suffix=new Vector<>();
        suffix.add(words[i + 1]);
        chain.put(words[i],suffix);
      }
 else {
        suffix.add(words[i + 1]);
        chain.put(words[i],suffix);
      }
    }
  }
}

public void addWords ( String phrase ) { if ( phrase . equals ( "#" ) || phrase . equals ( "" ) ) return ; String [ ] words = spliterator ( phrase ) ; if ( words . length < 2 ) return ; for ( int i = 0 ; i < words . length ; i ++ ) { if ( i == 0 ) { Vector < String > startWords = chain . get ( "_start" ) ; startWords . add ( words [ i ] ) ; Vector < String > suffix = chain . get ( words [ i ] ) ; if ( suffix == null ) { suffix = new Vector < > ( ) ; suffix . add ( words [ i + 1 ] ) ; chain . put ( words [ i ] , suffix ) ; } } else if ( i == words . length - 1 ) { Vector < String > endWords = chain . get ( "_end" ) ; endWords . add ( words [ i ] ) ; } else { Vector < String > suffix = chain . get ( words [ i ] ) ; if ( suffix == null ) { suffix = new Vector < > ( ) ; suffix . add ( words [ i + 1 ] ) ; chain . put ( words [ i ] , suffix ) ; } else { suffix . add ( words [ i + 1 ] ) ; chain . put ( words [ i ] , suffix ) ; } } } }
add words from phrase to chain
