MCPcopy
hub / github.com/fxsjy/jieba / add_word

Method add_word

jieba/__init__.py:418–437  ·  view source on GitHub ↗

Add a word to dictionary. freq and tag can be omitted, freq defaults to be a calculated value that ensures the word can be cut out.

(self, word, freq=None, tag=None)

Source from the content-addressed store, hash-verified

416 self.add_word(word, freq, tag)
417
418 def add_word(self, word, freq=None, tag=None):
419 """
420 Add a word to dictionary.
421
422 freq and tag can be omitted, freq defaults to be a calculated value
423 that ensures the word can be cut out.
424 """
425 self.check_initialized()
426 word = strdecode(word)
427 freq = int(freq) if freq is not None else self.suggest_freq(word, False)
428 self.FREQ[word] = freq
429 self.total += freq
430 if tag:
431 self.user_word_tag_tab[word] = tag
432 for ch in xrange(len(word)):
433 wfrag = word[:ch + 1]
434 if wfrag not in self.FREQ:
435 self.FREQ[wfrag] = 0
436 if freq == 0:
437 finalseg.add_force_split(word)
438
439 def del_word(self, word):
440 """

Callers 5

load_userdictMethod · 0.95
del_wordMethod · 0.95
suggest_freqMethod · 0.95
test_userdict.pyFile · 0.80
test_cutall.pyFile · 0.80

Calls 3

check_initializedMethod · 0.95
suggest_freqMethod · 0.95
strdecodeFunction · 0.85

Tested by

no test coverage detected