コード例 #1
0
  /** Parses the main vowel. */
  private void parseMainVowel() {
    if (!validViSyll) return;
    if (iCurPos > strSyllable.length() - 1) {
      validViSyll = false;
      return;
    }

    String strVowel = "";
    for (int i = iCurPos; i < strSyllable.length(); ++i) {
      int idx = vnVowels.indexOf(strSyllable.charAt(i));
      if (idx == -1) break;

      strVowel += vnVowels.charAt((idx / 6) * 6);
      if (tone.getValue() == TONE.NO_TONE.getValue()) tone = TONE.getTone(idx % 6);
    }

    Iterator iter = alMainVowels.iterator();
    while (iter.hasNext()) {
      String tempVowel = (String) iter.next();
      if (strVowel.startsWith(tempVowel)) {
        strMainVowel = tempVowel;
        iCurPos += tempVowel.length();
        return;
      }
    }
    validViSyll = false;
    return;
  }
コード例 #2
0
  /** Parses the secondary vowel. */
  private void parseSecondaryVowel() {
    if (!validViSyll) return;
    // get the current and next character in the syllable string
    char curChar, nextChar;
    if (iCurPos > strSyllable.length() - 1) {
      validViSyll = false;
      return;
    }
    curChar = strSyllable.charAt(iCurPos);

    if (iCurPos == strSyllable.length() - 1) nextChar = '$';
    else nextChar = strSyllable.charAt(iCurPos + 1);

    // get the tone and the original vowel (without tone)
    TONE tone = TONE.NO_TONE;
    int idx1 = vnVowels.indexOf(curChar);
    int idx2 = vnVowels.indexOf(nextChar);

    if (idx1 == -1) return; // current char is not a vowel
    tone = TONE.getTone(idx1 % 6);
    curChar = vnVowels.charAt((idx1 / 6) * 6);

    if (idx2 == -1) { // next char is not a vowel
      strSecondaryVowel = ZERO;
      return;
    }
    nextChar = vnVowels.charAt((idx2 / 6) * 6);
    if (tone.getValue() == TONE.NO_TONE.getValue()) tone = TONE.getTone(idx2 % 6);

    // Check the secondary vowel
    if (curChar == 'o') {
      if (nextChar == 'a' || nextChar == 'e') {
        strSecondaryVowel += curChar;
        iCurPos++;
      } else strSecondaryVowel = ZERO; // oo
      return;
    } else if (curChar == 'u') {
      if (nextChar != 'i' && nextChar != '$') {
        strSecondaryVowel += curChar;
        iCurPos++;
      } else strSecondaryVowel = ZERO;
      return;
    }
  }