import collections
import json


def load_queries(path: str):
    """
    Loads queries into a dictionary of query_id -> (query, question)
    """
    queries = collections.OrderedDict()
    with open(path) as f:
        raw_json = f.read()
        parsed_json = json.loads(raw_json)
        for topic in parsed_json:
            # Question ID is the integer question ID prefixed with "CQ"
            # or "EQ" depending on whether it's a consumer or expert question.
            # This has to be parsed out so it can be joined against the run
            # file.
            question_id_string = topic["question_id"]
            # The prefix is of length 2.
            question_id = int(question_id_string[2:])
            question = topic["question"]
            query = topic["query"]
            queries[question_id] = (query, question)

    return queries