Merge branch 'master' into jieba3k

This commit is contained in:
Sun Junyi 2013-04-28 19:32:14 +08:00
commit de9e7f61c3
2 changed files with 18 additions and 7 deletions

View File

@ -25,18 +25,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)

View File

@ -45,8 +45,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