|
|
@@ -105,7 +105,8 @@ public class KnowledgeBaseV3Service {
|
|
|
Map<String, Object> entry = (Map<String, Object>) item;
|
|
|
String name = (String) entry.get("名称");
|
|
|
if (name != null && !name.isEmpty()) {
|
|
|
- sectionIndex.put(name, entry);
|
|
|
+ // 归一化防止部首变体导致的重复条目(后写入覆盖前写入,结果一致)
|
|
|
+ sectionIndex.put(normalizeIndicatorName(name), entry);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -201,8 +202,9 @@ public class KnowledgeBaseV3Service {
|
|
|
*/
|
|
|
public Map<String, Object> lookupIndicator(String indicatorName) {
|
|
|
if (indicatorName == null || indicatorName.isEmpty()) return null;
|
|
|
+ String normalized = normalizeIndicatorName(indicatorName);
|
|
|
for (Map<String, Map<String, Object>> section : indicatorIndex.values()) {
|
|
|
- Map<String, Object> result = section.get(indicatorName);
|
|
|
+ Map<String, Object> result = section.get(normalized);
|
|
|
if (result != null) return result;
|
|
|
}
|
|
|
return null;
|
|
|
@@ -214,7 +216,7 @@ public class KnowledgeBaseV3Service {
|
|
|
public Map<String, Object> lookupIndicatorInSection(String sectionName, String indicatorName) {
|
|
|
Map<String, Map<String, Object>> section = indicatorIndex.get(sectionName);
|
|
|
if (section == null) return null;
|
|
|
- return section.get(indicatorName);
|
|
|
+ return section.get(normalizeIndicatorName(indicatorName));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -262,6 +264,20 @@ public class KnowledgeBaseV3Service {
|
|
|
return new ArrayList<>(foodIndex.values());
|
|
|
}
|
|
|
|
|
|
+ // ==================== 字符归一化 ====================
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 归一化指标名称:将 Kangxi 部首等变体转为标准 CJK 统一汉字
|
|
|
+ * 报告提取的文本中常出现部首形式(如 ⻔ U+2ED4),而 KB 储存标准汉字(门 U+95E8)
|
|
|
+ */
|
|
|
+ private String normalizeIndicatorName(String name) {
|
|
|
+ if (name == null || name.isEmpty()) return name;
|
|
|
+ // ⻔(U+2ED4)/(U+2F3C) → 门(U+95E8)
|
|
|
+ name = name.replace('\u2ed4', '\u95e8');
|
|
|
+ name = name.replace('\u2f3c', '\u95e8');
|
|
|
+ return name;
|
|
|
+ }
|
|
|
+
|
|
|
// ==================== 原始数据 ====================
|
|
|
|
|
|
/**
|