commit
a62a5d3968
@ -0,0 +1,21 @@
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
/.idea
|
||||
*.iml
|
||||
/.settings
|
||||
/bin
|
||||
/gen
|
||||
/build
|
||||
/gradle
|
||||
/classes
|
||||
.classpath
|
||||
.project
|
||||
*.gradle
|
||||
gradlew
|
||||
local.properties
|
||||
node_modules/
|
||||
data/
|
@ -0,0 +1,44 @@
|
||||
package xyz.wbsite.ai;
|
||||
|
||||
import com.hankcs.hanlp.HanLP;
|
||||
import com.hankcs.hanlp.corpus.tag.Nature;
|
||||
import com.hankcs.hanlp.seg.common.Term;
|
||||
import com.hankcs.hanlp.tokenizer.StandardTokenizer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HanLP_Example {
|
||||
public static void main(String[] args) {
|
||||
|
||||
// HanLPTokenizer hanLPTokenizer = new HanLPTokenizer();
|
||||
// String[] segment = hanLPTokenizer.segment("我喜欢吃苹果");
|
||||
//
|
||||
// List<String> 我喜欢吃苹果1 = HanLP.extractKeyword("我喜欢吃苹果", 2);
|
||||
//
|
||||
// HanLPEngine hanLPEngine = new HanLPEngine();
|
||||
// Result parse = hanLPEngine.parse("我喜欢吃苹果");
|
||||
//
|
||||
//
|
||||
// for (Word word : parse) {
|
||||
// System.out.println(word);
|
||||
// }
|
||||
|
||||
List<String> strings = HanLP.extractKeyword("身份证去哪里办理", 1);
|
||||
List<String> string = HanLP.extractKeyword("需要带什么材料", 1);
|
||||
|
||||
// 分词
|
||||
List<List<Term>> lists = StandardTokenizer.seg2sentence("那么还需要哪些材料");
|
||||
for (List<Term> list : lists) {
|
||||
for (Term term : list) {
|
||||
System.out.println(term);
|
||||
// 检查词性是否为主语相关的词性(例如:主谓宾中的主语通常是名词或代词)
|
||||
// if (term.nature.equals(Nature.n)) { // 名词
|
||||
// System.out.println("主语: " + term);
|
||||
// }
|
||||
// if (term.nature.equals(Nature.r)) { // 代词,例如“他”、“她”等
|
||||
// System.out.println("主语: " + term);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue