hanlp使用自定义词典抽取关键词

1.在data/dictionary/custom/路径下新建文件 myDict.txt.,添加新的单词,单词,词性,词频。并删除当前文件夹下的bin文件,

2.在hanlp配置文件中的CustomDictionaryPath后追加myDict.txt

3.工具类  

public static List <String> getNewExtractKeyWord(String content,Integer size){
List<Term> res = HanLP.segment(content);
TextRankKeyword textRankKeyword= new TextRankKeyword();
return textRankKeyword.getKeywords(res,size);
}

猜你喜欢

转载自www.cnblogs.com/Pluto-0609/p/10709362.html