mirror of
https://github.com/fxsjy/jieba.git
synced 2025-07-10 00:01:33 +08:00
Merge pull request #13 from felixonmars/master
add file-like object support for load_userdict
This commit is contained in:
commit
0ea6d8156d
@ -165,9 +165,11 @@ def cut(sentence,cut_all=False):
|
||||
if x!="":
|
||||
yield x
|
||||
|
||||
def load_userdict(f_name):
|
||||
def load_userdict(f):
|
||||
global trie,total,FREQ
|
||||
content = open(f_name,'rb').read().decode('utf-8')
|
||||
if isinstance(f, (str, unicode)):
|
||||
f = open(f, 'rb')
|
||||
content = f.read().decode('utf-8')
|
||||
for line in content.split("\n"):
|
||||
if line.rstrip()=='': continue
|
||||
word,freq = line.split(" ")
|
||||
|
Loading…
x
Reference in New Issue
Block a user