File size: 2,443 Bytes
37fcd19
 
 
 
 
 
13f78b2
 
 
 
37fcd19
 
 
 
 
 
 
 
 
 
13f78b2
 
37fcd19
 
 
 
 
 
 
 
 
 
 
13f78b2
 
37fcd19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
"""๊ฒฐํ•ฉ(bundle-v3) intent_positions.json (L1 grid ๋ฐฑ์—… ์ขŒํ‘œ) ์‚ฐ์ถœ. 5๊ฐœ L1 zone."""
import json
import math
from datetime import datetime
from pathlib import Path
import sys

sys.path.insert(0, str(Path(__file__).parent.parent))
from core.engines import config

L1_ZONES = {
    "INT-B1000": {"L1_name": "๊ฐ€์ž… ํ™•๋Œ€",       "centroid": (-0.55,  0.55), "color": "#10b981"},
    "INT-B2000": {"L1_name": "ํ• ์ธ ์ตœ์ ํ™”",     "centroid": ( 0.55,  0.55), "color": "#a855f7"},
    "INT-B3000": {"L1_name": "ํšŒ์„ /์„œ๋น„์Šค ํ™•์žฅ", "centroid": ( 0.00, -0.05), "color": "#3b82f6"},
    "INT-B4000": {"L1_name": "์œ ์ง€/๋ฝ์ธ",       "centroid": (-0.55, -0.55), "color": "#eab308"},
    "INT-B5000": {"L1_name": "์ดํƒˆ ๊ฒ€ํ† ",       "centroid": ( 0.60, -0.55), "color": "#1f2937"},
}
ZONE_RADIUS = 0.22

SCENARIO_ID = "bundle-v3"


def _place(i: int, total: int, centroid):
    cx, cy = centroid
    if total == 1:
        return cx, cy
    angle = 2 * math.pi * i / total
    r = ZONE_RADIUS * (0.45 if i < total / 2 else 0.95)
    return round(cx + r * math.cos(angle), 4), round(cy + r * math.sin(angle), 4)


def main():
    sdir = Path(__file__).parent.parent / "scenarios" / SCENARIO_ID
    intents = config.get_taxonomy(SCENARIO_ID)["intents"]
    by_l1 = {}
    for it in intents:
        by_l1.setdefault(it["L1_id"], []).append(it)

    positions = []
    for l1_id, group in by_l1.items():
        c = L1_ZONES[l1_id]["centroid"]
        for i, it in enumerate(group):
            x, y = _place(i, len(group), c)
            positions.append({"intent_id": it["id"], "L1_id": l1_id, "x": x, "y": y})

    payload = {
        "scenario_id": "bundle-v3",
        "embedding_model": "(backup: L1 grid)",
        "reducer": "(none)", "reducer_params": {}, "coord_range": [-1, 1],
        "generated_at": datetime.utcnow().isoformat() + "Z",
        "note": "L1 5๊ฐœ zone ๋™์‹ฌ์› ๋ฐฐ์น˜ ๋ฐฑ์—… ์ขŒํ‘œ.",
        "intents": positions,
        "l1_zones": [
            {"L1_id": k, "L1_name": v["L1_name"],
             "centroid": {"x": v["centroid"][0], "y": v["centroid"][1]}, "color": v["color"]}
            for k, v in L1_ZONES.items()
        ],
    }
    out = sdir / "intent_positions.json"
    json.dump(payload, open(out, "w", encoding="utf-8"), ensure_ascii=False, indent=2)
    print(f"Wrote {out} (intents={len(positions)}, zones={len(L1_ZONES)})")


if __name__ == "__main__":
    main()