tasks/vowels/preprocess.py
def generate_data(directory, total_examples):
    """
    Create a training (9 /10 of total_examples) and testing (1 / 10 of total_examples) files that each contain a
     single example of extracting vowels from a word. Each line in a given text files contains one character. Before
     the '#' character, the lines spell out a word. After the '#' character, the lines repeat the vowels instances in
     that word in their order of occurrence.
    :param directory: The directory in which to store training and testing examples
    :param total_examples: The total number of examples desired
    :return: None.
    """
    word_file = "/usr/share/dict/words"
    words = list(map(str.lower, open(word_file).read().splitlines()))
    for i in range(0, total_examples):
        my_inputs = list(words[i])
        if i < np.floor(total_examples * 9 / 10):
            path = join(directory, "%dtrain.txt" %i)
        else:
            path = join(directory, "%dtest.txt" %i)
        with open(path, "w+") as file:
            my_outputs = [letter for letter in my_inputs if letter in ['a', 'e', 'i', 'o', 'u']]
            for letter in my_inputs:
                file.write("%c\n" % letter)
            file.write("#\n")
            for letter in my_outputs:
                file.write("%c\n" % letter)

    Create a training (9 /10 of total_examples) and testing (1 / 10 of total_examples) files that each contain a
     single example of extracting vowels from a word. Each line in a given text files contains one character. Before
     the '#' character, the lines spell out a word. After the '#' character, the lines repeat the vowels instances in
     that word in their order of occurrence.
    :param directory: The directory in which to store training and testing examples
    :param total_examples: The total number of examples desired
    :return: None.
    
Create a training (9 /10 of total_examples) and testing (1 / 10 of total_examples) files that each contain a
single example of extracting vowels from a word. Each line in a given text files contains one character. Before
the '#' character, the lines spell out a word. After the '#' character, the lines repeat the vowels instances in
that word in their order of occurrence.
Create a training ( 9 / 10 of total_examples ) and testing ( 1 / 10 of total_examples ) files that each contain a single example of extracting vowels from a word . Each line in a given text files contains one character . Before the ' # ' character the lines spell out a word . After the ' # ' character the lines repeat the vowels instances in that word in their order of occurrence .
def generate_data(directory, total_examples):
    word_file = "/usr/share/dict/words"
    words = list(map(str.lower, open(word_file).read().splitlines()))
    for i in range(0, total_examples):
        my_inputs = list(words[i])
        if i < np.floor(total_examples * 9 / 10):
            path = join(directory, "%dtrain.txt" %i)
        else:
            path = join(directory, "%dtest.txt" %i)
        with open(path, "w+") as file:
            my_outputs = [letter for letter in my_inputs if letter in ['a', 'e', 'i', 'o', 'u']]
            for letter in my_inputs:
                file.write("%c\n" % letter)
            file.write("#\n")
            for letter in my_outputs:
                file.write("%c\n" % letter)
def generate_data ( directory , total_examples ) : word_file = "/usr/share/dict/words" words = list ( map ( str . lower , open ( word_file ) . read ( ) . splitlines ( ) ) ) for i in range ( 0 , total_examples ) : my_inputs = list ( words [ i ] ) if i < np . floor ( total_examples * 9 / 10 ) : path = join ( directory , "%dtrain.txt" % i ) else : path = join ( directory , "%dtest.txt" % i ) with open ( path , "w+" ) as file : my_outputs = [ letter for letter in my_inputs if letter in [ 'a' , 'e' , 'i' , 'o' , 'u' ] ] for letter in my_inputs : file . write ( "%c\n" % letter ) file . write ( "#\n" ) for letter in my_outputs : file . write ( "%c\n" % letter )
Create a training (9 /10 of total_examples) and testing (1 / 10 of total_examples) files that each contain a
single example of extracting vowels from a word.
Create a training ( 9 / 10 of total_examples ) and testing ( 1 / 10 of total_examples ) files that each contain a single example of extracting vowels from a word .
"""
    Create a training (9 /10 of total_examples) and testing (1 / 10 of total_examples) files that each contain a
     single example of extracting vowels from a word. Each line in a given text files contains one character. Before
     the '#' character, the lines spell out a word. After the '#' character, the lines repeat the vowels instances in
     that word in their order of occurrence.
    :param directory: The directory in which to store training and testing examples
    :param total_examples: The total number of examples desired
    :return: None.
    """
None
directory
The directory in which to store training and testing examples
The directory in which to store training and testing examples
total_examples
The total number of examples desired
The total number of examples desired