def _findBestSyllabification(inputIsleWordList, actualPronunciationList):
    '''
    Find the best syllabification for a word
    
    First find the closest pronunciation to a given pronunciation. Then take
    the syllabification for that pronunciation and map it onto the
    input pronunciation.
    '''
    retList = _findBestPronunciation(inputIsleWordList,
                                     actualPronunciationList)
    isleWordList, alignedAPronList, alignedSyllableList, bestIndex = retList
    
    alignedPhoneList = alignedAPronList[bestIndex]
    alignedSyllables = alignedSyllableList[bestIndex]
    syllabification = isleWordList[bestIndex][0]
    stressedSyllableIndexList = isleWordList[bestIndex][1]
    stressedPhoneIndexList = isleWordList[bestIndex][2]
    
    syllableList = _syllabifyPhones(alignedPhoneList, alignedSyllables)
    
    # Get the location of stress in the generated file
    try:
        stressedSyllableI = stressedSyllableIndexList[0]
    except IndexError:
        stressedSyllableI = None
        stressedVowelI = None
    else:
        stressedVowelI = _getSyllableNucleus(syllableList[stressedSyllableI])
    
    # Count the index of the stressed phones, if the stress list has
    # become flattened (no syllable information)
    flattenedStressIndexList = []
    for i, j in zip(stressedSyllableIndexList, stressedPhoneIndexList):
        k = j
        for l in range(i):
            k += len(syllableList[l])
        flattenedStressIndexList.append(k)
    
    return (stressedSyllableI, stressedVowelI, syllableList, syllabification,
            stressedSyllableIndexList, stressedPhoneIndexList,
            flattenedStressIndexList)
def _findBestSyllabification ( inputIsleWordList , actualPronunciationList ) : retList = _findBestPronunciation ( inputIsleWordList , actualPronunciationList ) isleWordList , alignedAPronList , alignedSyllableList , bestIndex = retList alignedPhoneList = alignedAPronList [ bestIndex ] alignedSyllables = alignedSyllableList [ bestIndex ] syllabification = isleWordList [ bestIndex ] [ 0 ] stressedSyllableIndexList = isleWordList [ bestIndex ] [ 1 ] stressedPhoneIndexList = isleWordList [ bestIndex ] [ 2 ] syllableList = _syllabifyPhones ( alignedPhoneList , alignedSyllables ) try : stressedSyllableI = stressedSyllableIndexList [ 0 ] except IndexError : stressedSyllableI = None stressedVowelI = None else : stressedVowelI = _getSyllableNucleus ( syllableList [ stressedSyllableI ] ) flattenedStressIndexList = [ ] for i , j in zip ( stressedSyllableIndexList , stressedPhoneIndexList ) : k = j for l in range ( i ) : k += len ( syllableList [ l ] ) flattenedStressIndexList . append ( k ) return ( stressedSyllableI , stressedVowelI , syllableList , syllabification , stressedSyllableIndexList , stressedPhoneIndexList , flattenedStressIndexList )
Find the best syllabification for a word
    
    First find the closest pronunciation to a given pronunciation. Then take
    the syllabification for that pronunciation and map it onto the
    input pronunciation.