From 3c8913e0e06d99e37cb6a26a022ae50a31abb8d5 Mon Sep 17 00:00:00 2001 From: Sun Junyi Date: Sat, 27 Apr 2013 16:21:48 +0800 Subject: [PATCH 1/2] Update README.md --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 792b899..5b7dbbb 100644 --- a/README.md +++ b/README.md @@ -21,18 +21,25 @@ http://jiebademo.ap01.aws.af.cm/ (Powered by Appfog) -Python Version -============== -* 目前master分支是只支持Python2.x 的 -* Python3.x 版本的分支也已经基本可用: https://github.com/fxsjy/jieba/tree/jieba3k -Usage -======== +Python 2.x 下的安装 +=================== * 全自动安装:`easy_install jieba` 或者 `pip install jieba` * 半自动安装:先下载http://pypi.python.org/pypi/jieba/ ,解压后运行python setup.py install * 手动安装:将jieba目录放置于当前目录或者site-packages目录 * 通过import jieba 来引用 (第一次import时需要构建Trie树,需要几秒时间) + +Python 3.x 下的安装 +==================== +* 目前master分支是只支持Python2.x 的 +* Python3.x 版本的分支也已经基本可用: https://github.com/fxsjy/jieba/tree/jieba3k + + git clone https://github.com/fxsjy/jieba.git + git checkout jieba3k + python setup.py install + + Algorithm ======== * 基于Trie树结构实现高效的词图扫描,生成句子中汉字所有可能成词情况所构成的有向无环图(DAG) From 35aa38ed125b1e713590a4b400aabf540af323d5 Mon Sep 17 00:00:00 2001 From: Sun Junyi Date: Sun, 28 Apr 2013 12:04:16 +0800 Subject: [PATCH 2/2] fix a bug caused by default argument binding --- jieba/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jieba/__init__.py b/jieba/__init__.py index 826b5d8..9cd2c6d 100644 --- a/jieba/__init__.py +++ b/jieba/__init__.py @@ -44,8 +44,12 @@ def gen_trie(f_name): raise e return trie, lfreq,ltotal -def initialize(dictionary=DICTIONARY): +def initialize(*args): global trie, FREQ, total, min_freq, initialized + if len(args)==0: + dictionary = DICTIONARY + else: + dictionary = args[0] with DICT_LOCK: if initialized: return