(self, segment, tune=False)
return freq
Suggest word frequency to force the characters in a word to be
        joined or splitted.

        Parameter:
            - segment : The segments that the word is expected to be cut into,
                        If the word should be treated as a whole, use a str.
            - tune : If True, tune the word frequency.

        Note that HMM may affect the final result. If the result doesn't change,
        set HMM=False.
Suggest word frequency to force the characters in a word to be
        joined or splitted.
Suggest word frequency to force the characters in a word to be joined or splitted .
def suggest_freq(self, segment, tune=False):
        """
        Suggest word frequency to force the characters in a word to be
        joined or splitted.

        Parameter:
            - segment : The segments that the word is expected to be cut into,
                        If the word should be treated as a whole, use a str.
            - tune : If True, tune the word frequency.

        Note that HMM may affect the final result. If the result doesn't change,
        set HMM=False.
        """
        self.check_initialized()
        ftotal = float(self.total)
        freq = 1
        if isinstance(segment, string_types):
            word = segment
            for seg in self.cut(word, HMM=False):
                freq *= self.FREQ.get(seg, 1) / ftotal
            freq = max(int(freq * self.total) + 1, self.FREQ.get(word, 1))
        else:
            segment = tuple(map(strdecode, segment))
            word = ''.join(segment)
            for seg in segment:
                freq *= self.FREQ.get(seg, 1) / ftotal
            freq = min(int(freq * self.total), self.FREQ.get(word, 0))
        if tune:
            add_word(word, freq)
        return freq
def suggest_freq ( self , segment , tune = False ) : self . check_initialized ( ) ftotal = float ( self . total ) freq = 1 if isinstance ( segment , string_types ) : word = segment for seg in self . cut ( word , HMM = False ) : freq *= self . FREQ . get ( seg , 1 ) / ftotal freq = max ( int ( freq * self . total ) + 1 , self . FREQ . get ( word , 1 ) ) else : segment = tuple ( map ( strdecode , segment ) ) word = '' . join ( segment ) for seg in segment : freq *= self . FREQ . get ( seg , 1 ) / ftotal freq = min ( int ( freq * self . total ) , self . FREQ . get ( word , 0 ) ) if tune : add_word ( word , freq ) return freq