File size: 6,379 Bytes
37fcd19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e000be4
2a06dbe
 
 
37fcd19
13f78b2
 
37fcd19
d504def
37fcd19
 
 
 
 
 
 
d504def
37fcd19
 
 
 
65ace42
 
37fcd19
d504def
37fcd19
 
 
 
 
 
 
d504def
37fcd19
 
 
 
 
 
 
d504def
37fcd19
 
 
 
 
 
 
d504def
37fcd19
 
 
 
 
 
 
d504def
37fcd19
 
 
 
 
 
 
d504def
37fcd19
 
 
 
 
 
 
d504def
37fcd19
 
 
 
 
 
 
d504def
37fcd19
 
 
 
 
2a06dbe
13f78b2
37fcd19
2a06dbe
e000be4
90eabe1
2a06dbe
 
 
37fcd19
2a06dbe
 
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python3
"""
์ง์žฅ์ธ(worker-v3) ํŽ˜๋ฅด์†Œ๋‚˜ ๊ธฐ๋ฐ˜ ์‹œ๋“œ ๋ฐ์ดํ„ฐ์…‹ ์ƒ์„ฑ.

๋‹จ์ผ ์•ฑ ์„ ํƒ(app_open) ๊ตฌ์กฐ. CS/๊ฒฐํ•ฉ๊ณผ ๋‹ฌ๋ฆฌ 2๋‹จ ํŠธ๋ฆฌ๊ฐ€ ์•„๋‹ˆ๋ผ ์•ฑ entity ์‹œํ€€์Šค.

์‹คํ–‰:
    cd roadshow-server-v3
    python scripts/build_worker_dataset.py --n 500 --seed 42
"""
from __future__ import annotations

import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).parent.parent))

from core.engines import config, get_engine  # noqa: E402
from scripts._dataset_common import (  # noqa: E402
    parse_args, build_samples, app_action_resolver, write_dataset, print_label_stats,
)

SCENARIO_ID = "worker-v3"
SCENARIO_DIR = Path(__file__).parent.parent / "scenarios" / SCENARIO_ID

# ํŽ˜๋ฅด์†Œ๋‚˜: answer_dist {qid:{code:w}}, app_seqs [[entity..]], expected_intents
PERSONAS = [
    {
        "id": "W1", "name": "๋ฒˆ์•„์›ƒ ์‹ฌํ™”ยท๋™๊ตดํ˜• (์ง‘์ฝ•ยท๊ณ ๋ฆฝ)", "weight": 0.14,
        "answer_dist": {"Q1": {"C": 0.4, "D": 0.3, "E": 0.3}, "Q2": {"B": 0.5, "C": 0.5}, "Q3": {"C": 0.4, "D": 0.6},
                        "Q4": {"C": 0.4, "D": 0.6}, "Q5": {"C": 0.4, "D": 0.6}, "Q6": {"A": 0.9, "B": 0.1},
                        "Q7": {"A": 0.8, "B": 0.2}, "Q8": {"A": 0.6, "B": 0.4}, "Q9": {"C": 0.6, "B": 0.4}},
        "app_seqs": [["music"], ["ott", "music"], ["music", "ott"]],
        "expected_intents": ["INT-W110", "INT-W130"],
    },
    {
        "id": "W2", "name": "๋ฒˆ์•„์›ƒ ์‹ฌํ™”ยท์—๋„ˆ์ง€ ์†Œ์ง„ (๋ฌด๊ธฐ๋ ฅ)", "weight": 0.13,
        "answer_dist": {"Q1": {"C": 0.4, "D": 0.3, "E": 0.3}, "Q2": {"A": 0.3, "B": 0.7}, "Q3": {"C": 0.5, "D": 0.5},
                        "Q4": {"C": 0.4, "D": 0.6}, "Q5": {"C": 0.5, "D": 0.5}, "Q6": {"A": 0.7, "B": 0.3},
                        "Q7": {"A": 0.4, "B": 0.4, "C": 0.2}, "Q8": {"A": 0.2, "B": 0.4, "C": 0.4}, "Q9": {"B": 0.5, "C": 0.5}},
        "app_seqs": [["delivery"], ["delivery", "ott"], ["ott", "delivery"]],
        "expected_intents": ["INT-W120", "INT-W210"],
    },
    {
        "id": "W3", "name": "์•ผ๊ฐ„ ์ž๊ทน ์ถ”๊ตฌ (์ˆ˜๋ฉด ๋ถ•๊ดด)", "weight": 0.12,
        "answer_dist": {"Q1": {"A": 0.3, "B": 0.3, "C": 0.4}, "Q2": {"B": 0.5, "C": 0.5}, "Q3": {"B": 0.5, "C": 0.5},
                        "Q4": {"C": 0.5, "D": 0.5}, "Q5": {"B": 0.4, "C": 0.6}, "Q6": {"A": 0.6, "B": 0.4},
                        "Q7": {"A": 0.5, "B": 0.5}, "Q8": {"B": 0.5, "C": 0.5}, "Q9": {"C": 0.9, "B": 0.1}},
        "app_seqs": [["sns"], ["ott"], ["sns", "ott"], ["ott", "sns"]],
        "expected_intents": ["INT-W130"],
    },
    {
        "id": "W4", "name": "์ฆ‰๊ฐ ๋ณด์ƒ ์ถ”๊ตฌ (๋ฐฐ๋‹ฌยท์‡ผํ•‘)", "weight": 0.12,
        "answer_dist": {"Q1": {"A": 0.4, "B": 0.3, "C": 0.3}, "Q2": {"B": 0.5, "C": 0.5}, "Q3": {"B": 0.5, "C": 0.5},
                        "Q4": {"C": 0.5, "D": 0.5}, "Q5": {"C": 0.5, "D": 0.5}, "Q6": {"A": 0.7, "B": 0.3},
                        "Q7": {"A": 0.5, "B": 0.5}, "Q8": {"B": 0.5, "C": 0.5}, "Q9": {"B": 0.5, "C": 0.5}},
        "app_seqs": [["delivery"], ["shopping"], ["delivery", "shopping"]],
        "expected_intents": ["INT-W210"],
    },
    {
        "id": "W5", "name": "์ผํƒˆยทํ™˜๊ฒฝ ์ „ํ™˜ ์š•๊ตฌ (์—ฌํ–‰)", "weight": 0.10,
        "answer_dist": {"Q1": {"A": 0.4, "B": 0.3, "C": 0.3}, "Q2": {"B": 0.5, "C": 0.5}, "Q3": {"B": 0.5, "C": 0.5},
                        "Q4": {"B": 0.4, "C": 0.6}, "Q5": {"B": 0.5, "C": 0.5}, "Q6": {"A": 0.5, "B": 0.5},
                        "Q7": {"B": 0.5, "C": 0.5}, "Q8": {"B": 0.5, "C": 0.5}, "Q9": {"B": 0.6, "C": 0.4}},
        "app_seqs": [["travel"], ["travel", "shopping"]],
        "expected_intents": ["INT-W220"],
    },
    {
        "id": "W6", "name": "์‹ ์ฒด ํšŒ๋ณต ์‹œ๋„ (์šด๋™)", "weight": 0.10,
        "answer_dist": {"Q1": {"A": 0.4, "B": 0.3, "C": 0.3}, "Q2": {"B": 0.5, "C": 0.5}, "Q3": {"B": 0.5, "C": 0.5},
                        "Q4": {"B": 0.5, "C": 0.5}, "Q5": {"B": 0.5, "C": 0.5}, "Q6": {"A": 0.5, "B": 0.5},
                        "Q7": {"B": 0.4, "C": 0.6}, "Q8": {"C": 0.5, "B": 0.5}, "Q9": {"A": 0.4, "B": 0.6}},
        "app_seqs": [["exercise"], ["exercise", "music"]],
        "expected_intents": ["INT-W230"],
    },
    {
        "id": "W7", "name": "์‹ฌ๋ฆฌยท๊ฐ์ • ํšŒ๋ณต (๋ช…์ƒ)", "weight": 0.10,
        "answer_dist": {"Q1": {"B": 0.4, "C": 0.3, "D": 0.3}, "Q2": {"B": 0.5, "C": 0.5}, "Q3": {"B": 0.5, "C": 0.5},
                        "Q4": {"C": 0.5, "D": 0.5}, "Q5": {"B": 0.5, "C": 0.5}, "Q6": {"A": 0.6, "B": 0.4},
                        "Q7": {"A": 0.5, "B": 0.5}, "Q8": {"A": 0.4, "B": 0.6}, "Q9": {"B": 0.6, "C": 0.4}},
        "app_seqs": [["mental_recovery"], ["mental_recovery", "music"], ["music", "mental_recovery"]],
        "expected_intents": ["INT-W240"],
    },
    {
        "id": "W8", "name": "์ผ์ƒ ํšŒ๋ณต (์ง€์ธ ์—ฐ๋ฝยท์ž๊ธฐ๊ณ„๋ฐœ)", "weight": 0.10,
        "answer_dist": {"Q1": {"A": 0.4, "B": 0.3, "C": 0.3}, "Q2": {"B": 0.5, "C": 0.5}, "Q3": {"B": 0.5, "C": 0.5},
                        "Q4": {"B": 0.5, "C": 0.5}, "Q5": {"A": 0.4, "B": 0.6}, "Q6": {"B": 0.6, "A": 0.4},
                        "Q7": {"B": 0.4, "C": 0.6}, "Q8": {"C": 0.4, "D": 0.6}, "Q9": {"A": 0.4, "B": 0.6}},
        "app_seqs": [["messenger"], ["reading"], ["messenger", "reading"]],
        "expected_intents": ["INT-W250"],
    },
    {
        "id": "W9", "name": "์ผ์ƒ ๋ฃจํ‹ด ๋ถ•๊ดด (๋ถˆ๊ทœ์น™)", "weight": 0.09,
        "answer_dist": {"Q1": {"B": 0.4, "C": 0.3, "D": 0.3}, "Q2": {"B": 0.5, "C": 0.5}, "Q3": {"C": 0.5, "D": 0.5},
                        "Q4": {"C": 0.4, "D": 0.6}, "Q5": {"C": 0.5, "D": 0.5}, "Q6": {"A": 0.7, "B": 0.3},
                        "Q7": {"A": 0.9, "B": 0.1}, "Q8": {"A": 0.6, "B": 0.4}, "Q9": {"B": 0.4, "C": 0.6}},
        "app_seqs": [["ott", "delivery"], ["sns", "delivery"], ["delivery", "ott", "sns"]],
        "expected_intents": ["INT-W140", "INT-W120"],
    },
]


def main():
    args = parse_args()
    entity_intents = config.get_behavior_signals(SCENARIO_ID)

    rows = build_samples(
        n=args.n, seed=args.seed, personas=PERSONAS, engine=get_engine(SCENARIO_ID),
        behavior_labels=False,
        seq_key="app_seqs", action_resolver=app_action_resolver,
        entity_intents=entity_intents, cust_prefix="WC",
    )

    write_dataset(SCENARIO_DIR / "seed_dataset.json", rows, SCENARIO_ID, len(PERSONAS), args.seed)
    print_label_stats(rows)


if __name__ == "__main__":
    main()