from typing import Tuple
from typing import List


def read_dataset(path: str) -> Tuple[List[List[str]], List[List[str]]]:
    """
    Reads a dataset from a given path.

    Args:
        path: Path of the file stored in tsv format.

    Returns:
        A 2D list of tokens and another of associated labels.
    """
    tokens_s = []
    labels_s = []

    tokens = []
    labels = []

    with open(path) as f:
        for line in f:
            line = line.strip()
            if line.startswith('# '):
                tokens = []
                labels = []
            elif line == '':
                tokens_s.append(tokens)
                labels_s.append(labels)
            else:
                _, token, label = line.split('\t')
                tokens.append(token)
                labels.append(label)

    assert len(tokens_s) == len(labels_s)

    return tokens_s, labels_s