(self, f)
Load personalized dict to improve detect rate.

        Parameter:
            - f : A plain text file contains words and their ocurrences.
                  Can be a file-like object, or the path of the dictionary file,
                  whose encoding must be utf-8.

        Structure of dict file:
        word1 freq1 word_type1
        word2 freq2 word_type2
        ...
        Word type may be ignored
Load personalized dict to improve detect rate.
Load personalized dict to improve detect rate .
def load_userdict(self, f):
        '''
        Load personalized dict to improve detect rate.

        Parameter:
            - f : A plain text file contains words and their ocurrences.
                  Can be a file-like object, or the path of the dictionary file,
                  whose encoding must be utf-8.

        Structure of dict file:
        word1 freq1 word_type1
        word2 freq2 word_type2
        ...
        Word type may be ignored
        '''
        self.check_initialized()
        if isinstance(f, string_types):
            f_name = f
            f = open(f, 'rb')
        else:
            f_name = resolve_filename(f)
        for lineno, ln in enumerate(f, 1):
            line = ln.strip()
            if not isinstance(line, text_type):
                try:
                    line = line.decode('utf-8').lstrip('\ufeff')
                except UnicodeDecodeError:
                    raise ValueError('dictionary file %s must be utf-8' % f_name)
            if not line:
                continue
            # match won't be None because there's at least one character
            word, freq, tag = re_userdict.match(line).groups()
            if freq is not None:
                freq = freq.strip()
            if tag is not None:
                tag = tag.strip()
            self.add_word(word, freq, tag)
def load_userdict ( self , f ) : self . check_initialized ( ) if isinstance ( f , string_types ) : f_name = f f = open ( f , 'rb' ) else : f_name = resolve_filename ( f ) for lineno , ln in enumerate ( f , 1 ) : line = ln . strip ( ) if not isinstance ( line , text_type ) : try : line = line . decode ( 'utf-8' ) . lstrip ( '\ufeff' ) except UnicodeDecodeError : raise ValueError ( 'dictionary file %s must be utf-8' % f_name ) if not line : continue # match won't be None because there's at least one character word , freq , tag = re_userdict . match ( line ) . groups ( ) if freq is not None : freq = freq . strip ( ) if tag is not None : tag = tag . strip ( ) self . add_word ( word , freq , tag )