diff --git a/kcui/src/view/Graph.vue b/kcui/src/view/Graph.vue index 9d58a8a..1ef79ac 100644 --- a/kcui/src/view/Graph.vue +++ b/kcui/src/view/Graph.vue @@ -350,7 +350,7 @@ export default { {size: 250, width: 250, height: 250, color: '30,255,0', font: 'normal 40px Arial', fontColor: '0,0,0'}, {size: 200, width: 200, height: 200, color: '248,143,248', font: 'normal 32px Arial', fontColor: '255,255,255'}, {size: 150, width: 150, height: 150, color: '65,154,255', font: 'normal 30px Arial', fontColor: '255,255,255'}, - {size: 100, width: 100, height: 100, color: '0,228,255', font: 'normal 28px Arial', fontColor: '0,0,0'} + {size: 120, width: 120, height: 120, color: '0,228,255', font: 'normal 28px Arial', fontColor: '0,0,0'} ]; return styles[group] || {}; diff --git a/src/main/java/com/main/woka/Common/util/RelationUtil.java b/src/main/java/com/main/woka/Common/util/RelationUtil.java index c91b3c7..7991177 100644 --- a/src/main/java/com/main/woka/Common/util/RelationUtil.java +++ b/src/main/java/com/main/woka/Common/util/RelationUtil.java @@ -1,9 +1,14 @@ package com.main.woka.Common.util; +import edu.stanford.nlp.pipeline.*; +import edu.stanford.nlp.ling.CoreAnnotations; +import edu.stanford.nlp.util.CoreMap; +import java.util.Properties; import edu.stanford.nlp.ling.CoreAnnotations; import edu.stanford.nlp.ling.CoreLabel; import edu.stanford.nlp.pipeline.Annotation; import edu.stanford.nlp.pipeline.StanfordCoreNLP; +import edu.stanford.nlp.util.CoreMap; import edu.stanford.nlp.util.StringUtils; import org.springframework.stereotype.Component; @@ -11,123 +16,8 @@ import java.util.*; @Component public class RelationUtil { - //标题分词 - public String analyzeRelationship(String title1, String title2) { - //载入properties 文件 - String[] args = new String[]{"-props", "CoreNLP-chinese.properties"}; - Properties properties = StringUtils.argsToProperties(args); - properties.setProperty("annotators", "tokenize, ssplit, pos"); - properties.setProperty("tokenize.language", "zh"); // 设置为中文 - - StanfordCoreNLP pipline = new StanfordCoreNLP(properties); - - // 分析第一个短语 "低温" - String phrase1 = title1; - List ll = analyzePhrase(pipline, phrase1); - - - //循环第一个短语的分词 - String useTitle = ""; - - for(int i=0;i analyzePhrase(StanfordCoreNLP pipeline, String phrase) { - List list = new ArrayList<>(); - Annotation document = new Annotation(phrase); - pipeline.annotate(document); - - List tokens = document.get(CoreAnnotations.TokensAnnotation.class); - for (CoreLabel token : tokens) { - String word = token.get(CoreAnnotations.TextAnnotation.class); - String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class); - System.out.println(word + ": " + pos); - Map mm = new HashMap(); - mm.put("text",word); - mm.put("pos",pos); - list.add(mm); - } - return list; - - } - - public String analyzePhrase1(StanfordCoreNLP pipeline, String phrase,String useTitle) { - Annotation document = new Annotation(phrase); - pipeline.annotate(document); - String title= ""; - String result =""; - Integer index = 0; - System.out.println(useTitle); - - List tokens = document.get(CoreAnnotations.TokensAnnotation.class); - for(int i=0;i analyzeRelationshipLong(String title1) { - List list = new ArrayList<>(); + public String analyzeRelationship(String title1, String title2) { String[] args = new String[]{"-props", "CoreNLP-chinese.properties"}; Properties properties = StringUtils.argsToProperties(args); properties.setProperty("annotators", "tokenize, ssplit, pos"); @@ -135,53 +25,38 @@ public class RelationUtil { StanfordCoreNLP pipline = new StanfordCoreNLP(properties); - // 分析第一个短语 "低温" - String phrase1 = title1; - List ll = analyzePhrase(pipline, phrase1); - - for(int i=0;i analyzeRelationshipLong1(String title1) { - List list = new ArrayList<>(); - String[] args = new String[]{"-props", "CoreNLP-chinese.properties"}; - Properties properties = StringUtils.argsToProperties(args); - properties.setProperty("annotators", "tokenize, ssplit, pos"); - properties.setProperty("tokenize.language", "zh"); // 设置为中文 - - StanfordCoreNLP pipline = new StanfordCoreNLP(properties); - - // 分析第一个短语 "低温" - String phrase1 = title1; - List ll = analyzePhrase(pipline, phrase1); - - for(int i=0;i ll = analyzePhrase(pipline, phrase1); + + + //循环第一个短语的分词 + String useTitle = ""; + + for(int i=0;i analyzePhrase(StanfordCoreNLP pipeline, String phrase) { + List list = new ArrayList<>(); + Annotation document = new Annotation(phrase); + pipeline.annotate(document); + + List tokens = document.get(CoreAnnotations.TokensAnnotation.class); + for (CoreLabel token : tokens) { + String word = token.get(CoreAnnotations.TextAnnotation.class); + String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class); + System.out.println(word + ": " + pos); + Map mm = new HashMap(); + mm.put("text",word); + mm.put("pos",pos); + list.add(mm); + } + return list; + + } + + public String analyzePhrase1(StanfordCoreNLP pipeline, String phrase,String useTitle) { + Annotation document = new Annotation(phrase); + pipeline.annotate(document); + String title= ""; + String result =""; + Integer index = 0; + System.out.println(useTitle); + + List tokens = document.get(CoreAnnotations.TokensAnnotation.class); + for(int i=0;i analyzeRelationshipLong(String title1) { + List list = new ArrayList<>(); + String[] args = new String[]{"-props", "CoreNLP-chinese.properties"}; + Properties properties = StringUtils.argsToProperties(args); + properties.setProperty("annotators", "tokenize, ssplit, pos"); + properties.setProperty("tokenize.language", "zh"); // 设置为中文 + + StanfordCoreNLP pipline = new StanfordCoreNLP(properties); + + // 分析第一个短语 "低温" + String phrase1 = title1; + List ll = analyzePhrase(pipline, phrase1); + + for(int i=0;i analyzeRelationshipLong1(String title1) { + List list = new ArrayList<>(); + String[] args = new String[]{"-props", "CoreNLP-chinese.properties"}; + Properties properties = StringUtils.argsToProperties(args); + properties.setProperty("annotators", "tokenize, ssplit, pos"); + properties.setProperty("tokenize.language", "zh"); // 设置为中文 + + StanfordCoreNLP pipline = new StanfordCoreNLP(properties); + + // 分析第一个短语 "低温" + String phrase1 = title1; + List ll = analyzePhrase(pipline, phrase1); + + for(int i=0;i