> 文章列表 > 【ansj分词,英文被转换为了小写】

【ansj分词,英文被转换为了小写】

【ansj分词,英文被转换为了小写】

ansj分词,英文被转换为了小写

  • 没有识别到词表
  • 解决方案
  • jieba分词


【ansj分词,英文被转换为了小写】

没有识别到词表

因为数据是大写,词表是大写,ansj将数据转换成了小写,无法匹配,词表失效。将词表改为小写就可以成功分词。

这里ansj我们的词表就是一列的词,没有涉及词频和权重

解决方案

但是数据想要保持原始,不想进行转换
MyStaticValue.isRealName = true ;即可
【ansj分词,英文被转换为了小写】

jieba分词

【ansj分词,英文被转换为了小写】
import com.huaban.analysis.jieba.JiebaSegmenter;
import com.huaban.analysis.jieba.WordDictionary;
import junit.framework.TestCase;
import org.junit.Test;

import java.nio.file.Paths;

public class jieba111 extends TestCase {
private JiebaSegmenter segmenter = new JiebaSegmenter();
String sentences = “你猜窝窝头好吃不”;

/* 读取conf目录下所有的自定义词库.dict文件。*/
@Override
protected void setUp() throws Exception {WordDictionary.getInstance().init(Paths.get("conf"));
}@Test
public void testCutForSearch() {System.out.println(segmenter.sentenceProcess(sentences));
}

}

大写英文如何控制保持原样,默认会转成小写:
https://github.com/NLPchina/ansj_seg/issues/168

使用jieba维护自定义词、停用词表
https://blog.csdn.net/daizongxue/article/details/78611025