Selaa lähdekoodia

1.添加抽取时间

hujing 5 vuotta sitten
vanhempi
commit
fb5e0ba37e

+ 26 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcess.java

@@ -5,9 +5,11 @@ import com.alibaba.fastjson.JSONObject;
 import com.lantone.qc.kernel.structure.ai.model.CrfOut;
 import com.lantone.qc.kernel.structure.ai.model.EntityEnum;
 import com.lantone.qc.kernel.structure.ai.model.Lemma;
+import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.kernel.structure.ai.model.Relation;
 import com.lantone.qc.pub.model.entity.DiagInfectious;
 import com.lantone.qc.pub.model.entity.Negative;
+import com.lantone.qc.pub.model.entity.PD;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.lang3.StringUtils;
 
@@ -170,6 +172,30 @@ public class EntityProcess {
         return null;
     }
 
+    /**
+     * 查找时间
+     * @param detailLemma
+     * @return
+     */
+    protected List<PD> findTime(Lemma detailLemma) {
+        List<PD> timestamps = new ArrayList<>();
+        String value;
+        for (Lemma lemma : detailLemma.getRelationLemmas()) {
+            if (lemma.getProperty().equals(EntityEnum.TIME.toString())) {
+                PD pd = new PD();
+                value = lemma.getText();
+                String[] valUnit = new String[2];;
+                if (value.trim().length() > 0) {
+                    valUnit = CatalogueUtil.extractDigit(value);
+                }
+                pd.setValue(valUnit[0]);
+                pd.setUnit(valUnit[1]);
+                timestamps.add(pd);
+            }
+        }
+        return timestamps;
+    }
+
     /**
      * 获取实体id列表对应的所有实体类型及实体值
      *