getTeinClass method

int getTeinClass(
  1. String latin
)

Implementation

int getTeinClass(String latin) {
  int iRet = 0;

  String word = latin;

  while (true && word.length > 1) {
    int cLast = word.codeUnitAt(word.length - 1);
    int cPreLast = word.codeUnitAt(word.length - 2);

    if ((cPreLast >= 'a'.codeUnits.first &&
            cPreLast <= 'z'.codeUnits.first) ||
        (cPreLast >= 'A'.codeUnits.first &&
            cPreLast <= 'Z'.codeUnits.first)) {
      if (cLast == 'a'.codeUnits.first ||
          cLast == 'o'.codeUnits.first ||
          cLast == 'v'.codeUnits.first) {
        iRet = 1;
        break;
      } else if (cLast == 'e'.codeUnits.first ||
          cLast == 'i'.codeUnits.first ||
          cLast == 'u'.codeUnits.first) {
        iRet = 2;
        break;
      } else if (cLast == 'p'.codeUnits.first ||
          cLast == 'h'.codeUnits.first ||
          cLast == 'x'.codeUnits.first ||
          cLast == 't'.codeUnits.first ||
          cLast == 'c'.codeUnits.first ||
          cLast == 'j'.codeUnits.first ||
          cLast == 'y'.codeUnits.first ||
          cLast == 'w'.codeUnits.first ||
          cLast == 'f'.codeUnits.first ||
          cLast == 'k'.codeUnits.first ||
          cLast == 'q'.codeUnits.first ||
          cLast == 'z'.codeUnits.first) {
        iRet = 3;
        break;
      } else if (cLast == 'n'.codeUnits.first) {
        iRet = 4;
        break;
      } else if (cLast == 'n'.codeUnits.first &&
          cPreLast == 'g'.codeUnits.first) {
        iRet = 5;
        break;
      } else if (cLast == 'b'.codeUnits.first ||
          cLast == 'g'.codeUnits.first ||
          cLast == 'r'.codeUnits.first ||
          cLast == 'r'.codeUnits.first ||
          cLast == 's'.codeUnits.first ||
          cLast == 'd'.codeUnits.first) {
        iRet = 6;
        break;
      } else {
        break;
      }
    }

    break;
  }

  return iRet;
}