Prechádzať zdrojové kódy

1- 调整返回数据类型。

bijl 5 rokov pred
rodič
commit
a0c05b9abe

+ 12 - 9
algorithm/src/main/java/org/algorithm/core/RelationTreeUtils.java

@@ -1,6 +1,7 @@
 package org.algorithm.core;
 
 import org.algorithm.core.cnn.entity.Lemma;
+import org.algorithm.core.cnn.entity.RelationTreeInfo;
 import org.algorithm.core.cnn.entity.Triad;
 
 import java.util.*;
@@ -79,7 +80,7 @@ public class RelationTreeUtils {
      * @param projectName 项目名称,如:核磁共振
      * @param triads      有关系,并且设置了父子节点关系的三元组
      */
-    public static Object[] getRelationTreeBranches(String projectName, List<Triad> triads) {
+    public static RelationTreeInfo getRelationTreeBranches(String projectName, List<Triad> triads) {
         List<Lemma> hasNoChildrenLemmas = new ArrayList<>();
         for (Triad triad : triads) {
             if (!triad.getL_1().isHasChildren())
@@ -99,9 +100,11 @@ public class RelationTreeUtils {
             branches.addAll(permute(aBranch));  // 排列
         }
 
-        Object[] obj = {projectName, branches};
+        RelationTreeInfo info = new RelationTreeInfo();
+        info.setBranches(branches);
+        info.setProjectName(projectName);
 
-        return obj;
+        return info;
     }
 
     /**
@@ -111,11 +114,11 @@ public class RelationTreeUtils {
      * @param triads
      * @return
      */
-    public static Object[] triadsToRelationTreeBranches(String projectName, List<Triad> triads) {
+    public static RelationTreeInfo triadsToRelationTreeBranches(String projectName, List<Triad> triads) {
         sameTextLemmaMerge(triads);
         buildRelationTree(triads);
-        Object[] obj = getRelationTreeBranches("胃造影", triads);
-        return obj;
+        RelationTreeInfo info = getRelationTreeBranches("胃造影", triads);
+        return info;
     }
 
     /**
@@ -202,10 +205,10 @@ public class RelationTreeUtils {
 
         sameTextLemmaMerge(triads);
         buildRelationTree(triads);
-        Object[] obj = getRelationTreeBranches("胃造影", triads);
+        RelationTreeInfo info = getRelationTreeBranches("胃造影", triads);
 
-        System.out.println(obj[0]);
-        System.out.println(obj[1]);
+        System.out.println(info.getProjectName());
+        System.out.println(info.getBranches());
     }
 
 }

+ 30 - 0
algorithm/src/main/java/org/algorithm/core/cnn/entity/RelationTreeInfo.java

@@ -0,0 +1,30 @@
+package org.algorithm.core.cnn.entity;
+
+import java.util.List;
+
+/**
+ * @Author: bijl
+ * @Date: 2019/9/9 16:52
+ * @Description:
+ */
+public class RelationTreeInfo {
+    private String projectName = null;
+    private List<List<String>> branches = null;
+
+    public String getProjectName() {
+        return projectName;
+    }
+
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
+    }
+
+    public List<List<String>> getBranches() {
+        return branches;
+    }
+
+    public void setBranches(List<List<String>> branches) {
+        this.branches = branches;
+    }
+
+}

+ 2 - 1
algorithm/src/main/java/org/algorithm/core/cnn/model/RelationExtractionEnsembleModel.java

@@ -4,6 +4,7 @@ import org.algorithm.core.RelationTreeUtils;
 import org.algorithm.core.RuleCheckMachine;
 import org.algorithm.core.cnn.AlgorithmCNNExecutor;
 import org.algorithm.core.cnn.dataset.RelationExtractionDataSet;
+import org.algorithm.core.cnn.entity.RelationTreeInfo;
 import org.algorithm.core.cnn.entity.Triad;
 import org.diagbot.pub.utils.PropertiesUtil;
 import org.tensorflow.SavedModelBundle;
@@ -187,7 +188,7 @@ public class RelationExtractionEnsembleModel extends AlgorithmCNNExecutor {
      * @param triads
      * @return
      */
-    public Object[] triadsToRelationTreeBranches(String projectName, List<Triad> triads) {
+    public RelationTreeInfo triadsToRelationTreeBranches(String projectName, List<Triad> triads) {
         return RelationTreeUtils.triadsToRelationTreeBranches(projectName, triads);
     }