词性标注修改

master
yz 2 years ago
parent 6eb60c7e56
commit 5fd2380e0d

@ -31,6 +31,8 @@
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>ruoyi-framework</artifactId> <artifactId>ruoyi-framework</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId> <artifactId>spring-boot-starter-data-mongodb</artifactId>

@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSONObject;
import com.hankcs.hanlp.corpus.document.sentence.Sentence; import com.hankcs.hanlp.corpus.document.sentence.Sentence;
import com.hankcs.hanlp.corpus.document.sentence.word.IWord; import com.hankcs.hanlp.corpus.document.sentence.word.IWord;
import com.hankcs.hanlp.corpus.document.sentence.word.Word; import com.hankcs.hanlp.corpus.document.sentence.word.Word;
import com.hankcs.hanlp.seg.common.Term;
import com.hankcs.hanlp.tokenizer.NotionalTokenizer;
import com.ruoyi.biemo.business.domain.Category; import com.ruoyi.biemo.business.domain.Category;
import com.ruoyi.biemo.business.domain.DocInfo; import com.ruoyi.biemo.business.domain.DocInfo;
import com.ruoyi.biemo.business.service.CategoryService; import com.ruoyi.biemo.business.service.CategoryService;

@ -15,7 +15,6 @@ import com.ruoyi.biemo.nlp.DependencyParserUtils;
import com.ruoyi.biemo.nlp.SummaryUtils; import com.ruoyi.biemo.nlp.SummaryUtils;
import com.ruoyi.biemo.utils.MyObjects; import com.ruoyi.biemo.utils.MyObjects;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequestBuilder;
import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.sort.SortOrder;
@ -71,7 +70,9 @@ public class DocInfoService extends EsService<DocInfo> {
if(id==null||id.trim().length()==0){ if(id==null||id.trim().length()==0){
return null; return null;
} }
List<DocInfo> docInfos = esLambdaQuery().eq(DocInfo::getId,id).query(); // List<DocInfo> docInfos = esLambdaQuery().eq(DocInfo::getId,id).query();
List<DocInfo> docInfos = esLambdaQuery().getDoc_InfoBy_Id(DocInfo::getId,id).query();
return docInfos!=null&&docInfos.size()>0?docInfos.get(0):null; return docInfos!=null&&docInfos.size()>0?docInfos.get(0):null;
} }

@ -661,6 +661,16 @@ public abstract class EsService<T> {
this.boolQueryBuilder.filter(QueryBuilders.termQuery(field, value)); this.boolQueryBuilder.filter(QueryBuilders.termQuery(field, value));
return this; return this;
} }
public EsQueryBuilder getDoc_InfoBy_Id(GFunction<? extends T, Object> gFunction, Object value) {
String field = gFunction.field();
field="_"+field;
this.searchSourceBuilder.postFilter(QueryBuilders.termQuery(field, value));
this.boolQueryBuilder.filter(QueryBuilders.termQuery(field, value));
return this;
}
public EsQueryBuilder eqAll(T t) { public EsQueryBuilder eqAll(T t) {
Field[] fields = t.getClass().getDeclaredFields(); Field[] fields = t.getClass().getDeclaredFields();
if(fields!=null&&fields.length>0){ if(fields!=null&&fields.length>0){

@ -27,9 +27,7 @@ public class DependencyParserUtils {
} }
public static Sentence nerAnalysis(String text) throws IOException { public static Sentence nerAnalysis(String text) throws IOException {
PerceptronLexicalAnalyzer analyzer = new PerceptronLexicalAnalyzer(HanLP.Config.PerceptronCWSModelPath, PerceptronLexicalAnalyzer analyzer = new PerceptronLexicalAnalyzer(HanLP.Config.PerceptronCWSModelPath, HanLP.Config.PerceptronPOSModelPath, HanLP.Config.PerceptronNERModelPath);
HanLP.Config.PerceptronPOSModelPath,
HanLP.Config.PerceptronNERModelPath);
//return NLPTokenizer.analyze(text); //return NLPTokenizer.analyze(text);
return analyzer.analyze(text); return analyzer.analyze(text);
} }

@ -24,6 +24,12 @@
<artifactId>classmate</artifactId> <artifactId>classmate</artifactId>
<version>1.3.4</version> <version>1.3.4</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.20</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>

Loading…
Cancel
Save