Skip to content

Instantly share code, notes, and snippets.

@inhzus
Created February 1, 2019 09:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inhzus/ea03d286838fb9afe7e20fba46c4ecd2 to your computer and use it in GitHub Desktop.
Save inhzus/ea03d286838fb9afe7e20fba46c4ecd2 to your computer and use it in GitHub Desktop.
HanLP seg2sentence
public static void main(String[] args) {
Segment segment = HanLP.newSegment().enableAllNamedEntityRecognize(false).enableCustomDictionary(false);
List<List<Term>> result = segment.seg2sentence("信里说他们离青云山还有很远,老祖宗说不着急,走个两三年也没什么打紧,所以他们走走停停," +
"有时听说哪里有好看好玩的事物,也会专门绕路过去,停驻几天。又说路上什么都好,哪怕是荒郊野外," +
"老祖宗也能变出热腾腾的吃食,还有各种衣物,穿戴比家里都要好。他们还自己动手搭过木屋,在一颗很高很大的树上," +
"建起了一座小小的屋子,为此他还专门学会了爬树…总之是一切都好,让父母大人不用担心他,老祖宗有个百宝囊,里面什么都有," +
"连书都有很多,没事的时候,他们就跟着老祖宗读书练字,最后祝高堂安泰。", true);
for (List<Term> sentence : result) {
for (Term term : sentence) {
System.out.printf("%s ", term.word);
}
System.out.print('\n');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment