from pathlib import Path
from typing import Tuple
from typing import List
from typing import Dict
import json


def get_dataset_from_json(jsonfilename: Path) -> Tuple[List[Dict[str, int]], List[str]]:
    """Loads dataset from json file.

    For each document, the json file contains dictionary
    with featurename -> value and string with translator's
    name.

    Parameters:
    jsonfilename: Path - Path object of file to load
    
    Returns:
    Tuple of lists. 
    First is list of dictionary of features.
    Second is list of strings with translators names
    """
    with open(jsonfilename, mode="r") as f:
        dataset = json.loads(f.read())
    X_dict = [features for features, _ in dataset]
    y_str = [translator for _, translator in dataset]
    return X_dict, y_str