You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
788 B
33 lines
788 B
|
|
import java.util.List;
|
|
|
|
import org.junit.Test;
|
|
|
|
import com.hankcs.hanlp.HanLP;
|
|
import com.hankcs.hanlp.dictionary.CustomDictionary;
|
|
import com.hankcs.hanlp.seg.Segment;
|
|
import com.hankcs.hanlp.seg.common.Term;
|
|
|
|
public class test{
|
|
|
|
@Test
|
|
public void TestA(){
|
|
String lineStr = "明天虽然会下雨,但是我还是会看周杰伦的演唱会。";
|
|
try{
|
|
Segment segment = HanLP.newSegment();
|
|
segment.enableCustomDictionary(true);
|
|
/**
|
|
* 自定义分词+词性
|
|
*/
|
|
CustomDictionary.add("虽然会","ng 0");
|
|
List<Term> seg = segment.seg(lineStr);
|
|
for (Term term : seg) {
|
|
System.out.println(term.toString());
|
|
}
|
|
}catch(Exception ex){
|
|
System.out.println(ex.getClass()+","+ex.getMessage());
|
|
}
|
|
}
|
|
|
|
}
|