Need to import the IK corresponding jar package
IKAnalyzer2012. jar
Lucene-core-4.10.jar
Public Static voidMain (string[] args)throwsIOException {//String text= "a lightweight Chinese word breaker toolkit developed based on Java language"; String Text= "Song zu English training course, Zhou Yu District service center, Joey Yung Children's Hospital, Wu chest hospitals, Souyong rehabilitation Center, Tony Leung's monopoly, Chen Hope Primary School, Wu Yan ancestral tcm Square, forest book luxury hotel"; //Create a Participle objectAnalyzer Anal=NewIkanalyzer (true); StringReader Reader=NewStringReader (text); //participletokenstream TS=anal.tokenstream ("", reader); Chartermattribute Term=ts.getattribute (Chartermattribute.class); //traversing word breaker dataTs.reset (); while(Ts.incrementtoken ()) {System.out.print (term.tostring () )+"|"); } ts.close (); Reader.close (); System.out.println (); }
Participle Result:
Song Zuying | training | zhouyumin | government | Service CENTER | Joey Yung | child | hospital | wu | chest | hospital | William So | | | | | | | | | | | | | | | | | | |
IK uses Java code to implement participle