hanlp 如果自己加了词典 语义就出不来,他直接拿下标的,但是要是语义拿不到能不能也不要报错,大不了给个null
public static void addDic(){
boolean add = CustomDictionary.add("后天", time);
}
// 分词
List<Term> termList = StandardTokenizer.segment(sentence);
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at com.hankcs.hanlp.seg.common.Vertex.guessNature(Vertex.java:313)
at com.hankcs.hanlp.recognition.nr.PersonRecognition.roleObserve(PersonRecognition.java:88)
at com.hankcs.hanlp.recognition.nr.PersonRecognition.Recognition(PersonRecognition.java:34)
at com.hankcs.hanlp.seg.Viterbi.ViterbiSegment.segSentence(ViterbiSegment.java:78)
at com.hankcs.hanlp.seg.Segment.seg(Segment.java:523)
at com.hankcs.hanlp.tokenizer.StandardTokenizer.segment(StandardTokenizer.java:40)
at top.starp.util.HanLPUtil.extractTimeRange(HanLPUtil.java:26)
at top.starp.util.HanLPUtil.main(HanLPUtil.java:78)
/**
* 猜测最可能的词性,也就是这个节点的词性中出现频率最大的那一个词性
*
* @return
*/
public Nature guessNature()
{
return attribute.nature[0];
}
文档:hanlp 如果自己加了词典 语义就出不来
链接:http://note.youdao.com/noteshare?id=ff1069d01481b9d5d06a098c33f88270&sub=C22E4E568BB946FC8221928B04CD82BF