HanLP
HanLP copied to clipboard
通过train函数对中文语料训练CRF模型时出错
注意事项
请确认下列注意事项:
- 我已仔细阅读下列文档,都没有找到答案:
- 我已经通过Google和issue区检索功能搜索了我的问题,也没有找到答案。
- 我明白开源社区是出于兴趣爱好聚集起来的自由社区,不承担任何责任或义务。我会礼貌发言,向每一个帮助我的人表示感谢。
- [x] 我在此括号内输入x打钩,代表上述事项确认完毕。
版本号
当前最新版本号是:1.7.1 我使用的版本是:1.7.1
我的问题
在通过train函数对中文语料训练CRF模型,得到模型文件CWS_MODEL_FILE 时,一直出错,并且如果CRFSegmenter停用,CRFLexicalAnalyzer接口没有相关的训练函数,该怎么对语料进行训练CRF模型?
复现问题
触发代码
public static void main(String[] args) throws Exception {
//CRFTrain();
testCWS();
}
//通过train函数对中文语料训练CRF模型,得到模型文件CWS_MODEL_FILE
public static void CRFTrain() throws Exception
{
CRFSegmenter segmenter = new CRFSegmenter(null);
segmenter.train(CORPUSPATH,CWS_MODEL_FILE);
}
//通过CRFSegmenter函数和CRF模型文件CWS_MODEL_FILE,对测试语句进行分词
public static void testCWS() throws Exception
{
//CRFSegmenter segmenter = new CRFSegmenter(CWS_MODEL_FILE);
CRFSegmenter segmenter = new CRFSegmenter();
List<String> wordList = segmenter.segment(SENTENCE);
System.out.println(wordList);
}
}
期望输出
测试上述代码, 在得到CRF模型语句segmenter.train(CORPUSPATH,CWS_MODEL_FILE);时出错