-
Notifications
You must be signed in to change notification settings - Fork 2.3k
配置文件说明
ansj edited this page Jun 6, 2016
·
7 revisions
在默认情况下,如果你想做更多的全局设定在程序调用时候,配置文件是个必不可少的玩意,在ansj中配置文件名为
library.properties
,这是一个不可更改的约定.下面让我们看看都有哪些选项在这个配置文件中.
字段名 | 默认值 | 说明 |
---|---|---|
isNameRecognition | true | 是否开启人名识别 |
isNumRecognition | true | 是否开启数字识别 |
isQuantifierRecognition | true | 是否数字和量词合并 |
isRealName | false | 是否取得真实的词,默认情况会取得标注化后的 |
dic | "library/default.dic" | 自定义词典路径 |
dic_[key] | "你的词典路径" | 针对不同语料调用不同的自定义词典 |
ambiguityLibrary | "library/ambiguity.dic" | 歧义词典路径 |
isSkipUserDefine | false | 是否用户辞典不加载相同的词 |
crf | null | crf词典路径,不设置为默认 |
crf_[key] | "你的模型路径" | 针对不同语料调用不同的分词模型 |
#path of userLibrary this is default library
dic=library/default.dic
#redress dic file path
ambiguityLibrary=library/ambiguity.dic
#set real name
isRealName=true
#isNameRecognition default true
isNameRecognition=true
#isNumRecognition default true
isNumRecognition=true
#digital quantifier merge default true
isQuantifierRecognition=true
默认情况下.放入到classpath中,来加载,但是很多时候,鬼知道classpath死哪去了,所以在你不知道的情况下,放到项目根目录还算是很保险的一个做法,程序默认在classpath中找不到的情况下,会尝试在启动目录的后两级开始找,当然项目启动的时候会有一个log来显示配置文件是否加载成功!如下所示:
INFO: load library not find in classPath ! i find it in
.....ansj_seg/library.properties make sure it is your config!
细心的你也许会发现,这些key的变量完全对应代码中static field的变量,所以.我是通过反射给对象赋值的,所以你完全可以通过配置文件操作MyStaticValue.class中所有的static field.当然你可以无视这段话,就当我胡说八道呢吧!