import json


def load_stance_data(path):
    """
    Loads data for the stance detection task, formats it into a list, and returns this list.

    :param path: full path to the raw data
    :return: A list of json object pairs, corresponding to source tweets followed by a response to that tweet
    """
    data = []
    print('Loading raw Twitter data')
    with open(path) as file:
        for line in file:
            root_id = line.split('\t')[0]
            raw_data = json.loads(line.split('\t')[1])
            for tweet_id, tweet in raw_data.items():
                if root_id == tweet_id:
                    continue
                else:
                    data.append([raw_data[root_id], raw_data[tweet_id]])
    return data