from typing import Tuple
from typing import List
import csv
import json


def load_tsv_data(path: str) -> Tuple[List[str], List[List[str]], List[str]]:
    """Load arbitrary tsv file of formed like (id, dialogue, summary) with header
    each `dialogue` should be dumped json string from a list of utterances.
    ex) '["안녕", "잘가"]'

    Args:
        path: path of tsv file
    Returns:
        result of file, which is a tuple of ids, dialogues, summaries
    """
    ids = []
    dialogues = []
    summaries = []
    with open(path) as f:
        for row in csv.DictReader(f, delimiter="\t"):
            ids.append(row["id"])
            dialogues.append(json.loads(row["dialogue"]))
            summaries.append(row.get("summary"))
    return ids, dialogues, summaries