parent
6d611f7ce4
commit
a800017dd6
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>paz2s9bc5</name>
|
||||
<comment>Project paz2s9bc5 created by Buildship.</comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,2 @@
|
||||
connection.project.dir=
|
||||
eclipse.preferences.version=1
|
@ -0,0 +1,42 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.spark.SparkConf;
|
||||
import org.apache.spark.api.java.JavaRDD;
|
||||
import org.apache.spark.api.java.JavaSparkContext;
|
||||
import org.apache.spark.mllib.classification.NaiveBayes;
|
||||
import org.apache.spark.mllib.classification.NaiveBayesModel;
|
||||
import org.apache.spark.mllib.linalg.Vector;
|
||||
import org.apache.spark.mllib.linalg.Vectors;
|
||||
import org.apache.spark.mllib.regression.LabeledPoint;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.appleyk.process.ModelProcess;
|
||||
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 HanLPTest {
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in new issue