Get the number of syllables and phones in this word
    
    If maxFlag=True, use the longest pronunciation.  Otherwise, take the
    average length.
16233
def getNumPhones(isleDict, word, maxFlag):
    '''
    
    '''
    phoneCount = 0
    syllableCount = 0
    
    syllableCountList = []
    phoneCountList = []
    
    wordList = isleDict.lookup(word)
    entryList = zip(*wordList)
    
    for lookupResultList in entryList:
        syllableList = []
        for wordSyllableList in lookupResultList:
            syllableList.extend(wordSyllableList)
        
        syllableCountList.append(len(syllableList))
        phoneCountList.append(len([phon for phoneList in syllableList for
                                   phon in phoneList]))
    
    # The average number of phones for all possible pronunciations
    #    of this word
    if maxFlag is True:
        syllableCount += max(syllableCountList)
        phoneCount += max(phoneCountList)
    else:
        syllableCount += (sum(syllableCountList) /
                          float(len(syllableCountList)))
        phoneCount += sum(phoneCountList) / float(len(phoneCountList))
    
    return syllableCount, phoneCount
753462
private int commonPrefixLength() {
        // shorterText和longerText已经在父类JaroDistanceTextSimilarity中准备好了
        // 这里直接用就可以
        int result = 0;
        int len = shorterText.length();
        for (int i = 0; i < len; i++) {
            if (shorterText.charAt(i) != longerText.charAt(i)) {
                break;
            }
            result++;
            if(result >= MAXIMUM_CHARACTERS){
                // 最多4个字符即可
                return MAXIMUM_CHARACTERS;
            }
        }
        return result;
    }
324665
def readLongString(self):
        
        l = self.stream.read_ulong()

        bytes = self.stream.read(l)

        return self.context.getStringForBytes(bytes)
1149998
public static function averageSyllablesPerWord($strText, $strEncoding = '')
    {
        $intSyllableCount = 0;
        $intWordCount = Text::wordCount($strText, $strEncoding);
        $arrWords = explode(' ', $strText);
        for ($i = 0; $i < $intWordCount; $i++) {
            $intSyllableCount += self::syllableCount($arrWords[$i], $strEncoding);
        }
        $averageSyllables = (Maths::bcCalc($intSyllableCount, '/', $intWordCount));
        return $averageSyllables;
    }
457863
def longest_non_repeat_v1(string):
    
    if string is None:
        return 0
    dict = {}
    max_length = 0
    j = 0
    for i in range(len(string)):
        if string[i] in dict:
            j = max(dict[string[i]], j)
        dict[string[i]] = i + 1
        max_length = max(max_length, i - j + 1)
    return max_length
796057
private void computeMaximumContextLength() {
        int max = 0;
        for (int i=0; i<trans.length; ++i) {
            int len = trans[i].getMaximumContextLength();
            if (len > max) {
                max = len;
            }
        }
        setMaximumContextLength(max);
    }
936950
def len(self, text):
        
        if not isinstance(text, str):
            return len(text)

        return sum(self._EAW_MAP.get(east_asian_width(c), self.ambiguous_width)
                   for c in text)
101866
def T6(word, rules):
    ''''''
    offset = 0

    try:
        WORD, rest = tuple(word.split('.', 1))

        for vvv in long_vowel_sequences(rest):
            i = vvv.start(2)
            vvv = vvv.group(2)
            i += (2 if phon.is_long(vvv[:2]) else 1) + offset
            rest = rest[:i] + '.' + rest[i:]
            offset += 1

    except ValueError:
        WORD = word

    for vvv in long_vowel_sequences(WORD):
        i = vvv.start(2) + 2
        WORD = WORD[:i] + '.' + WORD[i:]

    try:
        WORD += '.' + rest

    except UnboundLocalError:
        pass

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

    return WORD, rules
1245520
private static int guessNumDistinctiveGrams(int textLength, int gramLength) {
        switch (gramLength) {
            case 1:
                return Math.min(80, textLength);
            case 2:
                if (textLength < 40) return textLength;
                if (textLength < 100) return (int)(textLength*0.8);
                if (textLength < 1000) return (int)(textLength * 0.6);
                return (int)(textLength * 0.5);
            case 3:
                if (textLength < 40) return textLength;
                if (textLength < 100) return (int)(textLength*0.9);
                if (textLength < 1000) return (int)(textLength * 0.8);
                return (int)(textLength * 0.6);
            case 4:
            case 5:
            default:
                if (textLength < 100) return textLength;
                if (textLength < 1000) return (int)(textLength * 0.95);
                return (int)(textLength * 0.9);
        }
    }
873452
private int getMaxPartCount()
	{
		int max = 0;
		for (Object k : super.fWords.keySet())
		{
			String key = k.toString();
			int count = key.split("\\s+?").length;
			if (count > max)
			{
				max = count;
			}
		}
		return max;
	}
524227
def get_longest_line_length(text):
    """"""
    lines = text.split("\n")
    length = 0

    for i in range(len(lines)):
        if len(lines[i]) > length:
            length = len(lines[i])

    return length
649686
function maximizeLargeWord(word, hardBreakStr, maxWidth) {
    var availableWidth;
    var ch;
    var chWidth;
    var i;

    availableWidth = maxWidth - Format.width(hardBreakStr);

    for (i = 0; i < word.length; i++) {
        ch = word.charAt(i);
        chWidth = Format.width(ch);
        if (availableWidth >= chWidth) {
            availableWidth -= chWidth;
        } else {
            break;
        }
    }

    return {
        start: word.substr(0, i) + hardBreakStr,
        remaining: word.substr(i)
    };
}
690659
def _what_default(self, pronunciation):
        

        token_default = self['metadata']['token_default']['what']
        index_count = 2*len(pronunciation) + 1

        predictions = {}
        for i in range(index_count):
            index_predictions = {}

            if i % 2 == 0:
                index_predictions.update(token_default['0'])

            else:
                presented_phoneme = pronunciation[int((i-1)/2)]
                index_predictions[presented_phoneme] = token_default['1']['=']
                index_predictions['*'] = token_default['1']['*']
                index_predictions[''] = token_default['1']['']

            predictions['{}'.format(i)] = index_predictions

        return predictions
1302405
public static function maximumWords($mode, $version)
        {
            if($mode == QR_MODE_STRUCTURE) 
                return 3;
                
            if($version <= 9) {
                $l = 0;
            } else if($version <= 26) {
                $l = 1;
            } else {
                $l = 2;
            }

            $bits = self::$lengthTableBits[$mode][$l];
            $words = (1 << $bits) - 1;
            
            if($mode == QR_MODE_KANJI) {
                $words *= 2; // the number of bytes is required
            }

            return $words;
        }
742258
def get_random_word(dictionary, min_word_length=3, max_word_length=8):
    

    while True:
        # Choose a random word
        word = choice(dictionary)
        # Stop looping as soon as we have a valid candidate
        if len(word) >= min_word_length and len(word) <= max_word_length:
            break

    return word
453089
def find_max_label_length(labels):
    """"""
    length = 0
    for i in range(len(labels)):
        if len(labels[i]) > length:
            length = len(labels[i])

    return length
65286
def findClosestPronunciation(inputIsleWordList, aPron):
    '''
    
    '''
    
    retList = _findBestPronunciation(inputIsleWordList, aPron)
    isleWordList = retList[0]
    bestIndex = retList[3]
    
    return isleWordList[bestIndex]