Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRF语料训练 ansj加载模型报错 #436

Closed
rtghbnm opened this issue Mar 13, 2017 · 4 comments
Closed

CRF语料训练 ansj加载模型报错 #436

rtghbnm opened this issue Mar 13, 2017 · 4 comments

Comments

@rtghbnm
Copy link

rtghbnm commented Mar 13, 2017

你好,按照https://github.com/NLPchina/ansj_seg/wiki/%E5%AE%9A%E5%88%B6%E4%BD%A0%E8%87%AA%E5%B7%B1%E7%9A%84CRF%E6%A8%A1%E5%9E%8B 链接定制了CRF模型
1、用的是swresult.txt语料
2、模板用的是

Unigram

U01:%x[-1,0]
U02:%x[0,0]
U03:%x[1,0]
U04:%x[-1,0]/%x[0,0]
U05:%x[0,0]/%x[1,0]
U06:%x[-1,0]/%x[1,0]

Bigram

B
3、最终训练出来了model和model.txt
用的是ansj 5.1.1版本来加载定制的模型
报错:
CRFppTxtModel crfppTxtModel=new CRFppTxtModel();
String path = "src/main/resources/model.txt";
CRFppTxtModel model = crfppTxtModel.loadModel(path);
System.out.println(new SplitWord(model).cut("结婚的和尚未结婚的"));
}

Exception in thread "main" java.lang.Exception: err tag named U in model null
at org.ansj.app.crf.model.CRFppTxtModel.loadTagCoven(CRFppTxtModel.java:256)
at org.ansj.app.crf.model.CRFppTxtModel.loadModel(CRFppTxtModel.java:57)
at org.ansj.app.crf.model.CRFppTxtModel.loadModel(CRFppTxtModel.java:39)
at org.ansj.app.crf.ModelTest.main(ModelTest.java:46)

这是什么原因?
谢谢了

@winder8x
Copy link

CRFppTxtModel.loadModel
大约58行,少读了一个
tmp = reader.readLine();// xsize //by gongjan 读取头信息

@ansjsun
Copy link
Member

ansjsun commented Mar 21, 2017

你要是测试过了..帮加上呗..commit下代码

@winder8x
Copy link

好多地方都读不懂,等我明白了:)

@tianshuaifei
Copy link

六月 07, 2017 5:46:15 下午 org.ansj.library.CrfLibrary error
严重: org.ansj.domain.KV@3ac46dcf load err Unexpected end of ZLIB input stream
六月 07, 2017 5:46:15 下午 org.ansj.dic.impl.File2Stream info
信息: path to stream D:/Java/workspace/bwNLP/library/model/crf.model
六月 07, 2017 5:46:15 下午 org.ansj.library.CrfLibrary error
严重: org.ansj.domain.KV@5973b262 load err Unexpected end of ZLIB input stream
六月 07, 2017 5:46:15 下午 org.ansj.library.DATDictionary info
信息: init core library ok use time : 370
六月 07, 2017 5:46:16 下午 org.ansj.library.NgramLibrary info
信息: init ngram ok use time :1259
六月 07, 2017 5:46:16 下午 org.ansj.splitWord.analysis.NlpAnalysis warn
警告: not find any crf model, make sure your config right?

@ansjsun ansjsun closed this as completed Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants