Skip to content

Commit

Permalink
fix a bug of cxfree support
Browse files Browse the repository at this point in the history
  • Loading branch information
fxsjy committed Jun 23, 2013
1 parent a9f53e9 commit e1afafe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions jieba/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,8 @@ def set_dictionary(dictionary_path):
raise Exception("path does not exists:" + abs_path)
DICTIONARY = abs_path
initialized = False

def get_abs_path_dict():
_curpath=os.path.normpath( os.path.join( os.getcwd(), os.path.dirname(__file__) ) )
abs_path = os.path.join(_curpath,DICTIONARY)
return abs_path
6 changes: 3 additions & 3 deletions jieba/posseg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def load_model(f_name):
return eval(open(prob_p_path,"rb").read())
else:
result = {}
for line in open(prob_p_path,"rb"):
for line in open(f_name,"rb"):
line = line.strip()
if line=="":continue
word, _, tag = line.split(' ')
result[word.decode('utf-8')]=tag
return result

word_tag_tab = load_model("../dict.txt")
word_tag_tab = load_model(jieba.get_abs_path_dict())

if jieba.user_word_tag_tab:
word_tag_tab.update(jieba.user_word_tag_tab)
Expand Down Expand Up @@ -142,7 +142,7 @@ def __cut_internal(sentence):
tmp = re_skip.split(blk)
for x in tmp:
if re_skip.match(x):
yield pair(x,'')
yield pair(x,'x')
else:
for xx in x:
if re_num.match(xx):
Expand Down

0 comments on commit e1afafe

Please sign in to comment.