def load_data(filepath, split = True):
    """
        Load and return the data stored in the given path.
        The data is structured as follows: 
            Each line contains four columns separated by a single space. 
            Each word has been put on a separate line and there is an empty line after each sentence. 
            The first item on each line is a word, the second, third and fourth are tags related to the word.
        Example:
            The sentence "L. Antonielli, Iprefetti dell' Italia napoleonica, Bologna 1983." is represented in the dataset as:
                L author b-secondary b-r
                . author i-secondary i-r
                Antonielli author i-secondary i-r
                , author i-secondary i-r
                Iprefetti title i-secondary i-r
                dell title i-secondary i-r
                ’ title i-secondary i-r
                Italia title i-secondary i-r
                napoleonica title i-secondary i-r
                , title i-secondary i-r
                Bologna publicationplace i-secondary i-r
                1983 year e-secondary i-r
                . year e-secondary e-r
                
        IMPORTANT NOTE: by convention, the first line of every loaded dataset is empty.

        :param filepath: Path to the data
        :param split: return word and tags as separated lists if True (default for compatibility).
        :return: If split:
                 - True: four arrays: The first one contains sentences (one array of words per sentence) and the other threes are arrays of tags.
                 - False: a matrix, each row is a line and columns are: word, tag1, tag2, tag3.

    """

    # Arrays to return if splitted dataset rows
    words = []
    tags_1 = []
    tags_2 = []
    tags_3 = []
    
    # Array to return if full dataset rows
    rows = []
    

    word = tags1 = tags2 = tags3 = row = []
    with open (filepath, "r", encoding='utf8') as file:
        for line in file:
            if 'DOCSTART' not in line: #Do not take the first line into consideration
                # Check if empty line
                if line in ['\n', '\r\n']:
                    # Append line
                    # as splitted columns
                    words.append(word)
                    tags_1.append(tags1)
                    tags_2.append(tags2)
                    tags_3.append(tags3)
                    # as whole row
                    row = [word, tags1, tags2, tags3]
                    rows.append(row)

                    # Reset
                    word = []
                    tags1 = []
                    tags2 = []
                    tags3 = []

                else:
                    # Split the line into words, tag #1, tag #2, tag #3
                    w = line[:-1].split(" ")
                    word.append(w[0])
                    tags1.append(w[1])
                    tags2.append(w[2])
                    tags3.append(w[3])
                    

    if split:
        return words,tags_1,tags_2,tags_3
    else:
        return rows