There is a syllable boundary within a sequence VV of two nonidentical
    vowels that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa].
186885
def apply_T2(word):
    ''''''
    T2 = ''
    WORD = word.split('.')

    for i, v in enumerate(WORD):

        if not contains_diphthong(v):
            VV = contains_VV(v)

            if VV:
                I = v.find(VV) + 1
                WORD[i] = v[:I] + '.' + v[I:]
                T2 = ' T2'

    word = '.'.join(WORD)

    return word, T2
746563
def apply_T1(word):
    ''''''
    WORD = _split_consonants_and_vowels(word)

    for k, v in WORD.iteritems():

        if k == 1 and is_consonantal_onset(v):
            WORD[k] = '.' + v

        elif is_consonant(v[0]) and WORD.get(k + 1, 0):
            WORD[k] = v[:-1] + '.' + v[-1]

    word = _compile_dict_into_word(WORD)

    return word
570737
def T11(word, rules):
    ''''''
    WORD = word
    offset = 0

    for vvv in precedence_sequences(WORD):
        i = vvv.start(1) + (1 if vvv.group(1)[-1] in 'uyUY' else 2) + offset
        WORD = WORD[:i] + '.' + WORD[i:]
        offset += 1

    rules += ' T11' if word != WORD else ''

    return WORD, rules
290933
def T4(word, rules):
    ''''''
    WORD = re.split(
        r'([ieaouäöy]+[^ieaouäöy]+\.*[ieaoäö]{1}(?:u|y)(?:\.*[^ieaouäöy]+|$))',  # noqa
        word, flags=re.I | re.U)

    PARTS = [[] for part in range(len(WORD))]

    for i, v in enumerate(WORD):

        if i != 0:
            vv = u_y_final_diphthongs(v)

            if vv:
                I = vv.start(1) + 1
                PARTS[i].append(v[:I] + '.' + v[I:])

        # include original form (non-application of rule)
        PARTS[i].append(v)

    WORDS = [w for w in product(*PARTS)]

    for WORD in WORDS:
        WORD = ''.join(WORD)
        RULES = rules + ' T4' if word != WORD else rules

        yield WORD, RULES
1328799
def sixtuple2baxter(chars, debug=False, rhymebook=None):
    
    if not rhymebook:
        rhymebook = _cd.GY

    if len(chars) != 6:
        raise ValueError('chars should be a sixtuple')
    
    # convert chars to long chars
    chars = gbk2big5(chars)

    # assign basic values
    she,hu,deng,diao,yun,sheng = list(chars) 
    
    # try converting the values to mch representations
    initial = rhymebook['sheng'].get(sheng, '?')
    final = rhymebook['yun'].get(yun, '?')
    tone = rhymebook['diao'].get(diao, '?')
    medial = rhymebook['hu'].get(hu, '?')
    division = rhymebook['deng'].get(deng, '?')
        
    # debug is for cross-checking
    if debug:
        return [(sheng, initial), (hu, medial), (deng, division),(yun, final),
                (diao, tone)]

    # check and raise error if things are not handled
    if "?" in [initial, final, tone, medial, division]:
        raise ValueError("Unrecognized elements in {0}.".format(
            ' '.join([initial, final, tone, medial, division])))

    # treat the final if division is 3 and they start with 'j', note that so
    # far, we don't handle chongnius
    final = final[1:] if final[0] == 'j' and division in '4' \
            else final
    final = final[1:] if final[0] == 'j' and division in '3' \
            else final

    # reduce finals starting with 'w'
    final = final[1:] if final[0] == 'w' else final
    
    # resolve the medial (the hu) by checking for labial initial
    medial = '' if (initial[0] in 'pbm' and '*' not in final) \
            or final[0] in 'u' \
            or 'o' in final and not '*' in final and not '?' in final \
            else medial
    
    # correct for initials with sandeng-i
    initial = initial[:-1] if initial.endswith('j') else initial

    # get the medial corrected by deng
    medial = "j" + medial if division == '3' \
            and 'i' not in final \
            and 'y' not in initial \
            else medial

    # deprive the rime from its leading "j" if we have a medial
    final = final[1:] if final[0] in 'j' and 'j' in medial else final
    final = final[1:] if final[0] in 'w' and 'w' in medial else final
    final = final[1:] if final[0] == '*' or final[0] == '?' else final
    final = 'i' + final[1:] if final[0] == '!' \
            and division == '4' \
            and 'i' not in final \
            and (initial[0] in "pbmkgx'" or initial.startswith('ng')) \
            else final

    # chongniu medial-re-order
    medial = 'j' + medial if division == '4' \
            and '!' in final \
            and 'j' not in medial \
            and (initial[0] in "pbmkgx'" or initial.startswith('ng')) \
            else medial

    final = final[1:] if final[0] == '!' else final
    
    # put everything together
    return [initial,medial,final,tone]
677853
def wsp(word):
    ''''''
    HEAVY = r'[ieaAoO]{1}[\.]*(u|y)[^ieaAoO]+(\.|$)'

    # # if the word is not monosyllabic, lop off the final syllable, which is
    # # extrametrical
    # if '.' in word:
    #     word = word[:word.rindex('.')]

    # gather the indices of syllable boundaries
    delimiters = [i for i, char in enumerate(word) if char == '.']

    if len(delimiters) % 2 != 0:
        delimiters.append(len(word))

    unstressed = []

    # gather the indices of unstressed positions
    for i, d in enumerate(delimiters):
        if i % 2 == 0:
            unstressed.extend(range(d + 1, delimiters[i + 1]))

    # find the number of unstressed heavy syllables
    heavies = re.finditer(HEAVY, word)
    violations = sum(1 for m in heavies if m.start(0) in unstressed)

    return violations
1234607
def all_unambiguous(sequence_str):
    
    result = [[]]
    for c in sequence_str:
        result = [i + [a] for i in result for a in _AMBIGUOUS_MAP.get(c, c)]
    return [''.join(i) for i in result]
455182
def non_fluents(self) -> Dict[str, PVariable]:
        ''''''
        return { str(pvar): pvar for pvar in self.pvariables if pvar.is_non_fluent() }
40798
def _long_by_nature(self, syllable):
        

        # Find diphthongs
        vowel_group = ''
        for char in syllable:
            if char in self.long_vowels:
                return True
            elif char not in self.sing_cons:
                vowel_group += char

        if vowel_group in self.diphthongs:
            return True
446635
def _equivalent(self, char, prev, next, implicitA):
        
        result = []
        if char.unichr != DevanagariCharacter._VIRAMA:
            result.append(char.equivalents[self.name])
        """ Append implicit A to consonants if the next character isn't a vowel. """
        if implicitA and char.isConsonant \
        and ((next is not None \
        and next.unichr != DevanagariCharacter._VIRAMA \
        and not next.isVowel) \
        or next is None):
            result.append(characterBlocks['DEVANAGARI']\
                   [DevanagariCharacter._LETTER_A].equivalents[self.name])
        return result
1254492
def apply_T1(word):
    ''''''
    # split consonants and vowels: 'balloon' -> ['b', 'a', 'll', 'oo', 'n']
    WORD = [w for w in re.split('([ieAyOauo]+)', word) if w]
    count = 0

    for i, v in enumerate(WORD):

        if i == 0 and is_consonant(v[0]):
            continue

        elif is_consonant(v[0]) and i + 1 != len(WORD):
            if is_cluster(v):  # WSP
                if count % 2 == 0:
                    WORD[i] = v[0] + '.' + v[1:]  # CC > C.C, CCC > C.CC

                else:
                    WORD[i] = '.' + v  # CC > .CC, CCC > .CCC

            # elif is_sonorant(v[0]) and is_cluster(v[1:]):  # NEW
            #     if count % 2 == 0:
            #         WORD[i] = v[0:2] + '.' + v[2:]

            #     else:
            #         WORD[i] = v[0] + '.' + v[1:]

            else:
                WORD[i] = v[:-1] + '.' + v[-1]  # CC > C.C, CCC > CC.C

            count += 1

    WORD = ''.join(WORD)
    RULE = ' T1' if word != WORD else ''

    return WORD, RULE
223714
public boolean precedesForAllOffsetTypesInBoth(final OffsetGroup other) {
    return charOffset().precedes(other.charOffset())
        && edtOffset().precedes(other.edtOffset())
        && (!byteOffset().isPresent() || !other.byteOffset().isPresent()
                || byteOffset().get().precedes(other.byteOffset().get()))
        && (!asrTime().isPresent() || !other.asrTime().isPresent()
                || asrTime().get().precedes(other.asrTime().get()));
  }
407318
def _adjustSyllabification(adjustedPhoneList, syllableList):
    '''
    
    '''
    i = 0
    retSyllableList = []
    for syllableNum, syllable in enumerate(syllableList):
        j = len(syllable)
        if syllableNum == len(syllableList) - 1:
            j = len(adjustedPhoneList) - i
        tmpPhoneList = adjustedPhoneList[i:i + j]
        numBlanks = -1
        phoneList = tmpPhoneList[:]
        while numBlanks != 0:
            
            numBlanks = tmpPhoneList.count(u"''")
            if numBlanks > 0:
                tmpPhoneList = adjustedPhoneList[i + j:i + j + numBlanks]
                phoneList.extend(tmpPhoneList)
                j += numBlanks
        
        for k, phone in enumerate(phoneList):
            if phone == u"''":
                syllable.insert(k, u"''")
        
        i += j
        
        retSyllableList.append(syllable)
    
    return retSyllableList
8581
def flag_dipthongs(self, syllables: List[str]) -> List[int]:
        
        long_positions = []
        for idx, syl in enumerate(syllables):
            for dipthong in self.constants.DIPTHONGS:
                if dipthong in syllables[idx]:
                    if not string_utils.starts_with_qu(syllables[idx]):
                        long_positions.append(idx)
        return long_positions
877830
function isCharVowel(char = '', includeY = true) {
  if (isEmpty(char)) return false;
  const regexp = includeY ? /[aeiouy]/ : /[aeiou]/;
  return char.toLowerCase().charAt(0).search(regexp) !== -1;
}
743864
def syllabify(self, word):
        """"""

        prefixes = self.language['single_syllable_prefixes']
        prefixes.sort(key=len, reverse=True)

        # Check if word is in exception dictionary
        if word in self.language['exceptions']:
            syllables = self.language['exceptions'][word]

        # Else, breakdown syllables for word
        else:
            syllables = []

            # Remove prefixes
            for prefix in prefixes:
                if word.startswith(prefix):
                    syllables.append(prefix)
                    word = re.sub('^%s' % prefix, '', word)
                    break

            # Initialize syllable to build by iterating through over characters
            syllable = ''

            # Get word length for determining character position in word
            word_len = len(word)

            # Iterate over characters to build syllables
            for i, char in enumerate(word):

                # Build syllable
                syllable = syllable + char
                syllable_complete = False

                # Checks to process syllable logic
                char_is_vowel = self._is_vowel(char)
                has_next_char = i < word_len - 1
                has_prev_char = i > 0

                # If it's the end of the word, the syllable is complete
                if not has_next_char:
                    syllable_complete = True

                else:
                    next_char = word[i + 1]
                    if has_prev_char:
                        prev_char = word[i - 1]

                    # 'i' is a special case for a vowel. when i is at the 
                    # beginning of the word (Iesu) or i is between 
                    # vowels (alleluia), then the i is treated as a 
                    # consonant (y) Note: what about compounds like 'adiungere'
                    if char == 'i' and has_next_char and self._is_vowel(next_char): 
                        if i == 0:
                            char_is_vowel = False
                        elif self._is_vowel(prev_char):
                            char_is_vowel = False

                    # Determine if the syllable is complete
                    if char_is_vowel:

                        if (
                                    (  # If the next character's a vowel
                                       self._is_vowel(
                                               next_char)  # And it doesn't compose a dipthong with the current character
                                       and not self._is_diphthong(char,
                                                                  next_char)  # And the current character isn't preceded by a q, unless followed by a u
                                       and not (
                                                           has_prev_char
                                                       and prev_char == "q"
                                                   and char == "u"
                                               and next_char != "u"
                                       )

                                       )
                                or (
                                        # If the next character's a consonant but not a double consonant, unless it's a mute consonant followed by a liquid consonant
                                        i < word_len - 2
                                        and (
                                                        (
                                                                    (
                                                                                        has_prev_char
                                                                                    and prev_char != "q"
                                                                                and char == "u"
                                                                            and self._is_vowel(word[i + 2])
                                                                    )
                                                                or (
                                                                                not has_prev_char
                                                                            and char == "u"
                                                                        and self._is_vowel(word[i + 2])
                                                                )
                                                        )
                                                    or (
                                                                        char != "u"
                                                                and self._is_vowel(word[i + 2])
                                                            and not self._is_diphthong(char, next_char)
                                                    )
                                                or (
                                                            self._is_mute_consonant_or_f(next_char)
                                                        and self._is_liquid_consonant(word[i + 2])
                                                )
                                        )

                                )
                        ):
                            syllable_complete = True

                    # Otherwise, it's a consonant
                    else:

                        if (  # If the next character's also a consonant (but it's not the last in the word)
                              (

                                          not self._is_vowel(next_char)
                                      and i < word_len - 2
                              )  # If the char's not a mute consonant followed by a liquid consonant
                              and not (
                                          self._is_mute_consonant_or_f(char)
                                      and self._is_liquid_consonant(next_char)
                              )  # If the char's not a c, p, or t followed by an h
                              and not (
                                          (
                                                              has_prev_char
                                                          and not self._is_vowel(prev_char)
                                                      and char in ['c', 'p', 't'] and next_char == 'h'
                                          )
                                      or (
                                                      not has_prev_char
                                                  and char in ['c', 'p', 't'] and next_char == 'h'
                                      )
                              )  # And it's not the only letter in the syllable
                              and not len(syllable) == 1

                              ):
                            syllable_complete = True

                # If it's a complete syllable, append it to syllables list and reset syllable
                if syllable_complete:
                    syllables.append(syllable)
                    syllable = ''

        return syllables
388862
def apply_T5(word):
    ''''''
    WORD = _split_consonants_and_vowels(word)

    for k, v in WORD.iteritems():

        if len(v) >= 3 and is_vowel(v[0]):
            vv = [v.find(i) for i in i_DIPHTHONGS if v.find(i) > 0]

            if any(vv):
                vv = vv[0]

                if vv == v[0]:
                    WORD[k] = v[:2] + '.' + v[2:]

                else:
                    WORD[k] = v[:vv] + '.' + v[vv:]

    word = _compile_dict_into_word(WORD)

    return word