mirror of
https://github.com/fxsjy/jieba.git
synced 2025-07-10 00:01:33 +08:00
Merge pull request #71 from chao787/feature_richard
Separate cal and IO process.
This commit is contained in:
commit
632a086035
@ -264,9 +264,15 @@ def load_userdict(f):
|
|||||||
if line_no==1:
|
if line_no==1:
|
||||||
word = word.replace(u'\ufeff',u"") #remove bom flag if it exists
|
word = word.replace(u'\ufeff',u"") #remove bom flag if it exists
|
||||||
if len(tup)==3:
|
if len(tup)==3:
|
||||||
user_word_tag_tab[word]=tup[2].strip()
|
add_word(word, freq, tup[2])
|
||||||
|
add_word(word, freq)
|
||||||
|
|
||||||
|
def add_word(word, freq, tag=None):
|
||||||
|
global FREQ, trie, total, user_word_tag_tab
|
||||||
freq = float(freq)
|
freq = float(freq)
|
||||||
FREQ[word] = log(freq / total)
|
FREQ[word] = log(freq / total)
|
||||||
|
if tag is not None:
|
||||||
|
user_word_tag_tab[word] = tag.strip()
|
||||||
p = trie
|
p = trie
|
||||||
for c in word:
|
for c in word:
|
||||||
if not c in p:
|
if not c in p:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user