Stage 4.1: remove remaining Japanese delivery field keys
This commit is contained in:
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import pymysql
|
import pymysql
|
||||||
@@ -90,6 +91,46 @@ def evaluate_match_expr(match_expr: dict[str, Any], context: dict[str, Any]) ->
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def load_local_field_name_rules() -> dict[str, FieldNameRule]:
|
||||||
|
mapping_path = Path(__file__).resolve().parent / "tasks" / "pbf" / "mappings" / "navsea_field_name_rules_v1.yaml"
|
||||||
|
if not mapping_path.exists():
|
||||||
|
return {}
|
||||||
|
|
||||||
|
rules: dict[str, FieldNameRule] = {}
|
||||||
|
current: dict[str, str] = {}
|
||||||
|
for raw_line in mapping_path.read_text(encoding="utf-8").splitlines():
|
||||||
|
line = raw_line.strip()
|
||||||
|
if not line or line.startswith("#") or line in {"ruleset: navsea_field_name_rules_v1", "rules:"}:
|
||||||
|
continue
|
||||||
|
if line.startswith("- field_name_jp:"):
|
||||||
|
if current.get("field_name_jp") and current.get("field_name_std"):
|
||||||
|
rules[current["field_name_jp"]] = FieldNameRule(
|
||||||
|
field_name_jp=current["field_name_jp"],
|
||||||
|
field_name_std=current["field_name_std"],
|
||||||
|
field_group_name=current.get("field_group", ""),
|
||||||
|
keep_in_delivery=current.get("keep_in_delivery", "true").lower() == "true",
|
||||||
|
keep_in_engineering=current.get("keep_in_engineering", "true").lower() == "true",
|
||||||
|
normalization_class=current.get("normalization_class", ""),
|
||||||
|
)
|
||||||
|
current = {"field_name_jp": line.split(":", 1)[1].strip()}
|
||||||
|
continue
|
||||||
|
if not current or ":" not in line:
|
||||||
|
continue
|
||||||
|
key, value = line.split(":", 1)
|
||||||
|
current[key.strip()] = value.strip()
|
||||||
|
|
||||||
|
if current.get("field_name_jp") and current.get("field_name_std"):
|
||||||
|
rules[current["field_name_jp"]] = FieldNameRule(
|
||||||
|
field_name_jp=current["field_name_jp"],
|
||||||
|
field_name_std=current["field_name_std"],
|
||||||
|
field_group_name=current.get("field_group", ""),
|
||||||
|
keep_in_delivery=current.get("keep_in_delivery", "true").lower() == "true",
|
||||||
|
keep_in_engineering=current.get("keep_in_engineering", "true").lower() == "true",
|
||||||
|
normalization_class=current.get("normalization_class", ""),
|
||||||
|
)
|
||||||
|
return rules
|
||||||
|
|
||||||
|
|
||||||
class NavSeaMappingRegistry:
|
class NavSeaMappingRegistry:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -182,6 +223,7 @@ class NavSeaMappingRegistry:
|
|||||||
)
|
)
|
||||||
for row in cur.fetchall()
|
for row in cur.fetchall()
|
||||||
}
|
}
|
||||||
|
field_name_rules.update(load_local_field_name_rules())
|
||||||
|
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -121,3 +121,38 @@ rules:
|
|||||||
keep_in_engineering: true
|
keep_in_engineering: true
|
||||||
normalization_class: numeric_normalization
|
normalization_class: numeric_normalization
|
||||||
notes: Legacy angle string is normalized into bearing_deg.
|
notes: Legacy angle string is normalized into bearing_deg.
|
||||||
|
- field_name_jp: ローマ字名称
|
||||||
|
field_name_std: name_romaji
|
||||||
|
field_group: labels
|
||||||
|
keep_in_delivery: true
|
||||||
|
keep_in_engineering: true
|
||||||
|
normalization_class: content_text
|
||||||
|
notes: Romaji place or object name remains available as normalized content text.
|
||||||
|
- field_name_jp: 目的分類番号
|
||||||
|
field_name_std: purpose_class_code
|
||||||
|
field_group: source_legacy
|
||||||
|
keep_in_delivery: true
|
||||||
|
keep_in_engineering: true
|
||||||
|
normalization_class: legacy_render_code
|
||||||
|
notes: Legacy purpose code is preserved under a standardized key.
|
||||||
|
- field_name_jp: 縮尺選択コード
|
||||||
|
field_name_std: scale_selection_code
|
||||||
|
field_group: source_legacy
|
||||||
|
keep_in_delivery: true
|
||||||
|
keep_in_engineering: true
|
||||||
|
normalization_class: legacy_render_code
|
||||||
|
notes: Legacy scale-selection code is preserved under a standardized key.
|
||||||
|
- field_name_jp: 表示重要度
|
||||||
|
field_name_std: display_priority_code
|
||||||
|
field_group: source_legacy
|
||||||
|
keep_in_delivery: true
|
||||||
|
keep_in_engineering: true
|
||||||
|
normalization_class: legacy_render_code
|
||||||
|
notes: Legacy display-priority code is preserved under a standardized key.
|
||||||
|
- field_name_jp: Sガイドページ
|
||||||
|
field_name_std: guide_page_ref
|
||||||
|
field_group: source_legacy
|
||||||
|
keep_in_delivery: true
|
||||||
|
keep_in_engineering: true
|
||||||
|
normalization_class: content_text
|
||||||
|
notes: Legacy guide-page reference is preserved under a standardized key.
|
||||||
|
|||||||
Reference in New Issue
Block a user