Forráskód Böngészése

现病史描述与专科检查相互矛盾添加提示信息

hujing 5 éve
szülő
commit
5106f335d2

+ 16 - 1
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH03059.java

@@ -5,8 +5,10 @@ import com.alibaba.fastjson.JSONObject;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.structure.ai.BeHospitalizedAI;
 import com.lantone.qc.kernel.structure.ai.model.ConflictFinder;
+import com.lantone.qc.kernel.structure.ai.model.EntityBlock;
 import com.lantone.qc.kernel.structure.ai.model.Lemma;
 import com.lantone.qc.kernel.structure.ai.model.Relation;
+import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.label.PresentLabel;
@@ -63,8 +65,21 @@ public class BEH03059 extends QCCatalogue {
         presentPairs = new Object[] { presentLemmas, presentRelations };
 
         List<Object[]> positionPairs = finder.findConflictPositions(checkPairs, presentPairs);
-        if (positionPairs.size() > 0){
+        if (positionPairs.size() > 0) {
             status.set("-1");
+            String infoStr = "";
+            for (int i = 0; i < positionPairs.size(); i++) {
+                if (i % 2 != 0) {
+                    String words = "";
+                    Object[] entityBlocks = positionPairs.get(i);
+                    for (Object o : entityBlocks) {
+                        EntityBlock entityBlock = (EntityBlock) o;
+                        words += entityBlock.getSearchWord() + "->";
+                    }
+                    infoStr = CatalogueUtil.concatInfo(infoStr, words.substring(0, words.length() - 2));
+                }
+            }
+            info.set(infoStr);
         }
     }
 

+ 1 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/model/ConflictFinder.java

@@ -197,6 +197,7 @@ public class ConflictFinder {
             //System.out.println("" + conflict + ":" + entityBlock_1 + " ---> " + entityBlock_2);
             if (conflict) {
                 conflictPositions.add(getPositions(entityBlock_1, entityBlock_2));
+                conflictPositions.add(new Object[]{entityBlock_1,entityBlock_2});
             }
         });
         return conflictPositions;

+ 1 - 3
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/model/EntityBlock.java

@@ -22,8 +22,6 @@ public class EntityBlock {
 
     @Override
     public String toString() {
-        return "EntityBlock{" +
-                "entityWords=" + entityWords +
-                '}';
+        return entityWords.toString().replaceAll("[\\[\\]]","");
     }
 }

+ 18 - 2
kernel/src/test/java/com/lantone/qc/kernel/KnowledgeTest.java

@@ -1,9 +1,11 @@
 package com.lantone.qc.kernel;
 
 import com.google.common.collect.Lists;
+import com.lantone.qc.kernel.structure.ai.model.EntityBlock;
 import com.lantone.qc.kernel.structure.ai.model.Lemma;
 import com.lantone.qc.kernel.structure.ai.model.ConflictFinder;
 import com.lantone.qc.kernel.structure.ai.model.Relation;
+import com.lantone.qc.kernel.util.CatalogueUtil;
 
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -84,8 +86,22 @@ public class KnowledgeTest {
         presentPairs = new Object[] {presentLemmas, presentRelations};
 
         List<Object[]> positionPairs = finder.findConflictPositions(checkPairs, presentPairs);
-
-        System.out.println("有冲突的位置组数目:" + positionPairs.size());
+        if (positionPairs.size() > 0) {
+            String info = "";
+            for (int i = 0; i < positionPairs.size(); i++) {
+                if (i % 2 != 0){
+                    String infoStr = "";
+                    Object[] entityBlocks = positionPairs.get(i);
+                    for (Object o:entityBlocks) {
+                        EntityBlock entityBlock = (EntityBlock) o;
+                        infoStr += entityBlock.getSearchWord() + "->";
+                    }
+                    info = CatalogueUtil.concatInfo(info, infoStr.substring(0, infoStr.length() - 2));
+                }
+            }
+            System.out.println(info);
+        }
+        System.out.println("有冲突的位置组数目:" + positionPairs.size()/2);
 
     }
 }