tasks/vowels/preprocess.py
def encode_data(files_list, lexicons_dictionary):
    """
    Encode the dataset into its numeric form given a constructed dictionary
    :param files_list: the list of files to scan through.
    :param lexicons_dictionary: the mappings of unique lexicons.
    :return: the data in its numeric form, maximum story length
    """

    files = {}

    llprint("Encoding Data ... 0/%d" % (len(files_list)))

    for indx, filename in enumerate(files_list):

        files[filename] = []

        with open(filename, 'r') as fobj:
            on_answer = False
            story_inputs = []
            story_outputs = []
            for line in fobj:
                word = line.strip()
                if on_answer:
                    story_outputs.append(lexicons_dictionary[word])
                else:
                    story_inputs.append(lexicons_dictionary[word])
                    if word == '#':
                        on_answer = True
            story_inputs.extend([lexicons_dictionary['#']] * len(story_outputs))
            files[filename].append({
                'inputs': story_inputs,
                'outputs': story_outputs
            })

        llprint("\rEncoding Data ... %d/%d" % (indx + 1, len(files_list)))

    print("\rEncoding Data ... Done!")
    return files

    Encode the dataset into its numeric form given a constructed dictionary
    :param files_list: the list of files to scan through.
    :param lexicons_dictionary: the mappings of unique lexicons.
    :return: the data in its numeric form, maximum story length
    
Encode the dataset into its numeric form given a constructed dictionary
Encode the dataset into its numeric form given a constructed dictionary
def encode_data(files_list, lexicons_dictionary):
    files = {}
    llprint("Encoding Data ... 0/%d" % (len(files_list)))
    for indx, filename in enumerate(files_list):
        files[filename] = []
        with open(filename, 'r') as fobj:
            on_answer = False
            story_inputs = []
            story_outputs = []
            for line in fobj:
                word = line.strip()
                if on_answer:
                    story_outputs.append(lexicons_dictionary[word])
                else:
                    story_inputs.append(lexicons_dictionary[word])
                    if word == '#':
                        on_answer = True
            story_inputs.extend([lexicons_dictionary['#']] * len(story_outputs))
            files[filename].append({
                'inputs': story_inputs,
                'outputs': story_outputs
            })
        llprint("\rEncoding Data ... %d/%d" % (indx + 1, len(files_list)))
    print("\rEncoding Data ... Done!")
    return files
def encode_data ( files_list , lexicons_dictionary ) : files = { } llprint ( "Encoding Data ... 0/%d" % ( len ( files_list ) ) ) for indx , filename in enumerate ( files_list ) : files [ filename ] = [ ] with open ( filename , 'r' ) as fobj : on_answer = False story_inputs = [ ] story_outputs = [ ] for line in fobj : word = line . strip ( ) if on_answer : story_outputs . append ( lexicons_dictionary [ word ] ) else : story_inputs . append ( lexicons_dictionary [ word ] ) if word == '#' : on_answer = True story_inputs . extend ( [ lexicons_dictionary [ '#' ] ] * len ( story_outputs ) ) files [ filename ] . append ( { 'inputs' : story_inputs , 'outputs' : story_outputs } ) llprint ( "\rEncoding Data ... %d/%d" % ( indx + 1 , len ( files_list ) ) ) print ( "\rEncoding Data ... Done!" ) return files
Encode the dataset into its numeric form given a constructed dictionary
Encode the dataset into its numeric form given a constructed dictionary
"""
    Encode the dataset into its numeric form given a constructed dictionary
    :param files_list: the list of files to scan through.
    :param lexicons_dictionary: the mappings of unique lexicons.
    :return: the data in its numeric form, maximum story length
    """
the data in its numeric form, maximum story length
the data in its numeric form maximum story length
files_list
the list of files to scan through.
the list of files to scan through .
lexicons_dictionary
the mappings of unique lexicons.
the mappings of unique lexicons .