mirror of
https://github.com/fxsjy/jieba.git
synced 2025-07-10 00:01:33 +08:00
Merge branch 'master' into jieba3k
This commit is contained in:
commit
de9e7f61c3
19
README.md
19
README.md
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user