wangyunpeng 1 week geleden
bovenliggende
commit
97048bdc7b
1 gewijzigde bestanden met toevoegingen van 62 en 40 verwijderingen
  1. 62 40
      core/src/main/java/com/tzld/videoVector/job/VideoVectorJob.java

+ 62 - 40
core/src/main/java/com/tzld/videoVector/job/VideoVectorJob.java

@@ -759,35 +759,39 @@ public class VideoVectorJob {
 
             // 4. 对每个通过置信度的点,提取实质/形式子项并检查贡献度
             for (String pointName : qualifiedPointNames) {
-                // 在主数组中匹配点
-                JSONObject matchedPoint = null;
-                for (JSONObject detail : pointDetails) {
-                    if (pointName.equals(detail.getString("点"))) {
-                        matchedPoint = detail;
-                        break;
+                try {
+                    // 在主数组中匹配点
+                    JSONObject matchedPoint = null;
+                    for (JSONObject detail : pointDetails) {
+                        if (pointName.equals(detail.getString("点"))) {
+                            matchedPoint = detail;
+                            break;
+                        }
+                    }
+                    if (matchedPoint == null) {
+                        log.info("point_decomposition: 未找到点 '{}' 的详情", pointName);
+                        continue;
                     }
-                }
-                if (matchedPoint == null) {
-                    log.info("point_decomposition: 未找到点 '{}' 的详情", pointName);
-                    continue;
-                }
 
-                // 根据 target 提取子项名称
-                List<String> itemNames;
-                if ("substance".equals(target)) {
-                    itemNames = extractSubstanceNames(matchedPoint);
-                } else {
-                    itemNames = extractFormNames(matchedPoint);
-                }
+                    // 根据 target 提取子项名称
+                    List<String> itemNames;
+                    if ("substance".equals(target)) {
+                        itemNames = extractSubstanceNames(matchedPoint);
+                    } else {
+                        itemNames = extractFormNames(matchedPoint);
+                    }
 
-                // 检查贡献度
-                for (String name : itemNames) {
-                    Double contribution = contributionMap.get(name);
-                    if (contribution != null && contribution >= contributionThreshold) {
-                        texts.add(name);
-                        log.info("point_decomposition: 通过贡献度检查, 点='{}', 名称='{}', 贡献度={}",
-                                pointName, name, contribution);
+                    // 检查贡献度
+                    for (String name : itemNames) {
+                        Double contribution = contributionMap.get(name);
+                        if (contribution != null && contribution >= contributionThreshold) {
+                            texts.add(name);
+                            log.info("point_decomposition: 通过贡献度检查, 点='{}', 名称='{}', 贡献度={}",
+                                    pointName, name, contribution);
+                        }
                     }
+                } catch (Exception e) {
+                    log.error("point_decomposition: 处理点 '{}' 异常: {}", pointName, e.getMessage());
                 }
             }
 
@@ -810,9 +814,14 @@ public class VideoVectorJob {
         if (substance == null) {
             return names;
         }
-        collectNamesFromArray(substance.getJSONArray("具体元素"), names);
-        collectNamesFromArray(substance.getJSONArray("具象概念"), names);
-        collectNamesFromArray(substance.getJSONArray("抽象概念"), names);
+        String[] keys = {"具体元素", "具象概念", "抽象概念"};
+        for (String key : keys) {
+            try {
+                collectNamesFromArray(substance.getJSONArray(key), names);
+            } catch (Exception e) {
+                log.error("extractSubstanceNames 提取 '{}' 异常: {}", key, e.getMessage());
+            }
+        }
         return names;
     }
 
@@ -826,9 +835,14 @@ public class VideoVectorJob {
         if (form == null) {
             return names;
         }
-        collectNamesFromArray(form.getJSONArray("具体元素形式"), names);
-        collectNamesFromArray(form.getJSONArray("具象概念形式"), names);
-        collectNamesFromArray(form.getJSONArray("整体形式"), names);
+        String[] keys = {"具体元素形式", "具象概念形式", "整体形式"};
+        for (String key : keys) {
+            try {
+                collectNamesFromArray(form.getJSONArray(key), names);
+            } catch (Exception e) {
+                log.error("extractFormNames 提取 '{}' 异常: {}", key, e.getMessage());
+            }
+        }
         return names;
     }
 
@@ -840,12 +854,16 @@ public class VideoVectorJob {
             return;
         }
         for (int i = 0; i < array.size(); i++) {
-            JSONObject item = array.getJSONObject(i);
-            if (item != null) {
-                String name = item.getString("名称");
-                if (StringUtils.hasText(name)) {
-                    names.add(name);
+            try {
+                JSONObject item = array.getJSONObject(i);
+                if (item != null) {
+                    String name = item.getString("名称");
+                    if (StringUtils.hasText(name)) {
+                        names.add(name);
+                    }
                 }
+            } catch (Exception e) {
+                log.error("collectNamesFromArray 第{}个元素解析异常: {}", i, e.getMessage());
             }
         }
     }
@@ -859,10 +877,14 @@ public class VideoVectorJob {
         try {
             List<JSONObject> contributions = VectorUtils.extractArrayItemsFromJson(dataContent, contributionPath + "[*]");
             for (JSONObject c : contributions) {
-                String word = c.getString("词");
-                Double contribution = c.getDouble("贡献度");
-                if (StringUtils.hasText(word) && contribution != null) {
-                    map.put(word, contribution);
+                try {
+                    String word = c.getString("词");
+                    Double contribution = c.getDouble("贡献度");
+                    if (StringUtils.hasText(word) && contribution != null) {
+                        map.put(word, contribution);
+                    }
+                } catch (Exception e) {
+                    log.error("解析贡献度条目异常: {}", e.getMessage());
                 }
             }
         } catch (Exception e) {