addChar method

void addChar(
  1. String ch
)

Implementation

void addChar(String ch) {
  ch = normalize(ch);
  String lastChar = grams[grams.length - 1];
  if (lastChar == ' ') {
    grams = ' ';
    capitalword = false;
    if (ch == ' ') {
      return;
    }
  } else if (grams.length >= nGram) {
    grams = grams.substring(1);
  }
  grams += ch;

  if (isUpperCase(ch)) {
    if (isUpperCase(lastChar)) {
      capitalword = true;
    }
  } else {
    capitalword = false;
  }
}