清梦了无痕唯爱如藤:Lucene 中文引擎,庖丁解牛的辞典参数配置方法(转)

来源:百度文库 编辑:中财网 时间:2024/04/27 14:44:45

随机文档指示可以在环境变量里配置。原文如下
庖丁中文分词需要一套词典,这些词典需要统一存储在某个目录下,这个目录称为词典安装目录。词典安装目录可以是文件系统的任何目录,它不依赖于应用程序的运行目录。将词典拷贝到词典安装目录的过程称为安装词典。增加、删除、修改词典目录下的词典的过程称为自定制词典。

在linux下,我们可以考虑将词典安装在一个专门存储数据的分区下某目录,以笔者为例,笔者将/data作为系统的一个独立分区,笔者便是将词典保存在/data/paoding/dic下。
在windows下,我们可以考虑将词典安装在非系统盘的另外分区下的某个目录,以笔者为例,笔者可能将词典保存在E:/data/paoding/dic下。
使用者安装辞典后,应该设置系统环境变量PAODING_DIC_HOME指向词典安装目录。
在linux下,通过修改/etc/profile,在文件末尾加上以下2行,然后保存该文件并退出即可。
PAODING_DIC_HOME=/data/paoding/dic
export PAODING_DIC_HOME
在windows下,通过“我的电脑”属性之“高级”选项卡,然后在进入“环境变量”编辑区,新建环境变量,设置“变量名”为PAODING_DIC_HOME;“变量值”为E:/data/paoding/dic


不过我在错误信息里面发现了另外一个配置方式,那就是修改paoding-dic-home.properties 里面的 paoding.dic.home 配置
这个文件在
paoding-analysis-2.0.4-beta\classes
有一个,我们可以修改这个,原始内容如下

#values are "system-env" or "this";
#if value is "this" , using the paoding.dic.home as dicHome if configed!
#paoding.dic.home.config-fisrt=system-env

#dictionary home (directory)
#"classpath:xxx" means dictionary home is in classpath.
#e.g "classpath:dic" means dictionaries are in "classes/dic" directory or any other classpath directory
#paoding.dic.home=dic

#seconds for dic modification detection
#paoding.dic.detector.interval=60


我们修改成如下内容
#values are "system-env" or "this";
#if value is "this" , using the paoding.dic.home as dicHome if configed!
# 这里修改为 this 代表使用这个配置而不是环境变量的配置
paoding.dic.home.config-fisrt=this

#dictionary home (directory)
#"classpath:xxx" means dictionary home is in classpath.
#e.g "classpath:dic" means dictionaries are in "classes/dic" directory or any other classpath directory
# 这里修改为我们辞典所在的目录
paoding.dic.home=E:/lib/paoding-analysis-2.0.4-beta/dic/

#seconds for dic modification detection
#paoding.dic.detector.interval=60


最后一步,用winrar/winzip等打开 paoding-analysis.jar 然后更新里面的 paoding-dic-home.properties

OK, 这个jar就是我们自己使用的了。

转自:http://hi.baidu.com/axhack/blog/item/2c00f663bb23be670c33fa7d.html