feat(est): reproduce native tables and calculations
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
"""Build read-only REA sample inputs and expected stored values; does not run EST."""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
ANALYSIS = ROOT / "resources/knowledge/original/경쟁사 프로그램/EST Plus 2/REA 분석"
|
||||
SOURCE = ANALYSIS / "07_수치검증_작업자료_20261025"
|
||||
DETAIL = ANALYSIS / "09_수식집계_변경저장_추적_20261029"
|
||||
|
||||
|
||||
def read(path):
|
||||
return json.loads(path.read_text(encoding="utf-8-sig"))
|
||||
|
||||
|
||||
def convert(value):
|
||||
if isinstance(value, dict) and "decimal" in value:
|
||||
return float(value["decimal"])
|
||||
return value
|
||||
|
||||
|
||||
def build():
|
||||
tables = {}
|
||||
for path in SOURCE.glob("*.decoded_candidates.json"):
|
||||
key = path.name.split(".")[0]
|
||||
tables[key] = [r["values"] for r in read(path)["rows"]]
|
||||
wonga = read(DETAIL / "WongaDat_memory_table_candidate_rows.json")
|
||||
table = next(t for t in wonga["tables"] if t["source"].endswith("_1_decompressed.bin"))
|
||||
tables["Wonga"] = [{k: convert(v) for k, v in row["values"].items()} for row in table["rows"]]
|
||||
sample = {
|
||||
"schema": "est-web-2",
|
||||
"name": "EST REA 보관 샘플",
|
||||
"tables": tables,
|
||||
"options": {"TotalFix": True, "VerFormat": True, "SourceRefresh": False},
|
||||
"quantities": [],
|
||||
"progress": [],
|
||||
"annual": [],
|
||||
"drawings": [],
|
||||
"evidence": "REA 저장 샘플. 물리 슬롯의 활성 여부 및 원본 실행 동등성은 별도 검증 대상.",
|
||||
}
|
||||
target = Path(__file__).parent / "sample.json"
|
||||
target.write_text(json.dumps(sample, ensure_ascii=False, allow_nan=False), encoding="utf-8")
|
||||
expected = {
|
||||
"qualification": "기존 REA 분석의 저장값. 웹앱 계산값으로 정답을 만들지 않음.",
|
||||
"machine": read(DETAIL / "machine_sample_formula_reconstruction_check.json"),
|
||||
"head_est": read(DETAIL / "head_est_sample_rule_check.json"),
|
||||
"linedata": read(DETAIL / "linedata_sample_precision_check.json"),
|
||||
"wonga": read(DETAIL / "sample_wonga_Gubun_formula_candidate_check.json"),
|
||||
}
|
||||
for check in expected["head_est"]["head"]:
|
||||
candidates = []
|
||||
for slot, row in enumerate(tables["HeadMainDat"]):
|
||||
if row.get("Name") != check.get("Name") or (
|
||||
"Code" in check and row.get("Code") != check["Code"]
|
||||
):
|
||||
continue
|
||||
if all(
|
||||
abs((row.get(key) or 0) - value) < 1e-6 for key, value in check["stored"].items()
|
||||
):
|
||||
candidates.append(slot)
|
||||
if not candidates:
|
||||
raise ValueError(f"head sample identity not found: {check}")
|
||||
check["source_slot"] = candidates[0]
|
||||
fixture = ROOT / "resources/tester/fixtures/est_rea_expected.json"
|
||||
fixture.write_text(json.dumps(expected, ensure_ascii=False, allow_nan=False), encoding="utf-8")
|
||||
(Path(__file__).parent / "parity.json").write_text(
|
||||
json.dumps(expected, ensure_ascii=False, allow_nan=False), encoding="utf-8"
|
||||
)
|
||||
print(f"sample: {sum(map(len, tables.values()))} records, {len(tables)} tables")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
build()
|
||||
Reference in New Issue
Block a user