tasks/DREAM/cleaning.py
def clean_word_array(word_array):
    """
    Fix syntax, spelling, and grammar errors in word_array. Note, that this function is only designed to account for
    errors in the DREAM dataset.
    :param word_array: An array of words from the DREAM dataset.
    :return: a new word array with equivalent or improved grammar/spelling/syntax.
    """
    new_word_array = word_array
    for word in word_array:
        if word in spacing_dict:
            new_words = spacing_dict[word].split()
            new_word_array = replace_word(new_word_array, {word: new_words})
        elif word in spelling_dict:
            new_words = [spelling_dict[word]]
            new_word_array = replace_word(new_word_array, {word: new_words})
        elif word.endswith("s'"):
            new_words = [word[:-1], "'s"]
            new_word_array = replace_word(new_word_array, {word: new_words})
        elif word in abbrivations:
            new_words = abbrivations[word].split()
            new_word_array = replace_word(new_word_array, {word: new_words})
        elif word.endswith("'s"):
            new_words = [clean_word_array([word[:-2]])[0], "'s"]
            new_word_array = replace_word(new_word_array, {word: new_words})
        elif word == "point":
            continue
        elif "-" in word:
            try:
                new_words = split_up_digits(str(w2n.word_to_num(word)))
                new_word_array = replace_word(new_word_array, {word: new_words})
            except ValueError:
                split_word = word.split("-")
                new_word_array = replace_word(new_word_array, {word: clean_word_array(split_word)})
        elif word.isnumeric():
            new_words = split_up_digits(word)
            new_word_array = replace_word(new_word_array, {word: new_words})
        else:
            try:
                new_words = split_up_digits(str(w2n.word_to_num(word)))
                new_word_array = replace_word(new_word_array, {word: new_words})
            except ValueError:
                continue
        if "'" in new_word_array:
            print(new_word_array)
    return new_word_array

    Fix syntax, spelling, and grammar errors in word_array. Note, that this function is only designed to account for
    errors in the DREAM dataset.
    :param word_array: An array of words from the DREAM dataset.
    :return: a new word array with equivalent or improved grammar/spelling/syntax.
    
Fix syntax, spelling, and grammar errors in word_array. Note, that this function is only designed to account for
errors in the DREAM dataset.
Fix syntax spelling and grammar errors in word_array . Note that this function is only designed to account for errors in the DREAM dataset .
def clean_word_array(word_array):
    new_word_array = word_array
    for word in word_array:
        if word in spacing_dict:
            new_words = spacing_dict[word].split()
            new_word_array = replace_word(new_word_array, {word: new_words})
        elif word in spelling_dict:
            new_words = [spelling_dict[word]]
            new_word_array = replace_word(new_word_array, {word: new_words})
        elif word.endswith("s'"):
            new_words = [word[:-1], "'s"]
            new_word_array = replace_word(new_word_array, {word: new_words})
        elif word in abbrivations:
            new_words = abbrivations[word].split()
            new_word_array = replace_word(new_word_array, {word: new_words})
        elif word.endswith("'s"):
            new_words = [clean_word_array([word[:-2]])[0], "'s"]
            new_word_array = replace_word(new_word_array, {word: new_words})
        elif word == "point":
            continue
        elif "-" in word:
            try:
                new_words = split_up_digits(str(w2n.word_to_num(word)))
                new_word_array = replace_word(new_word_array, {word: new_words})
            except ValueError:
                split_word = word.split("-")
                new_word_array = replace_word(new_word_array, {word: clean_word_array(split_word)})
        elif word.isnumeric():
            new_words = split_up_digits(word)
            new_word_array = replace_word(new_word_array, {word: new_words})
        else:
            try:
                new_words = split_up_digits(str(w2n.word_to_num(word)))
                new_word_array = replace_word(new_word_array, {word: new_words})
            except ValueError:
                continue
        if "'" in new_word_array:
            print(new_word_array)
    return new_word_array
def clean_word_array ( word_array ) : new_word_array = word_array for word in word_array : if word in spacing_dict : new_words = spacing_dict [ word ] . split ( ) new_word_array = replace_word ( new_word_array , { word : new_words } ) elif word in spelling_dict : new_words = [ spelling_dict [ word ] ] new_word_array = replace_word ( new_word_array , { word : new_words } ) elif word . endswith ( "s'" ) : new_words = [ word [ : - 1 ] , "'s" ] new_word_array = replace_word ( new_word_array , { word : new_words } ) elif word in abbrivations : new_words = abbrivations [ word ] . split ( ) new_word_array = replace_word ( new_word_array , { word : new_words } ) elif word . endswith ( "'s" ) : new_words = [ clean_word_array ( [ word [ : - 2 ] ] ) [ 0 ] , "'s" ] new_word_array = replace_word ( new_word_array , { word : new_words } ) elif word == "point" : continue elif "-" in word : try : new_words = split_up_digits ( str ( w2n . word_to_num ( word ) ) ) new_word_array = replace_word ( new_word_array , { word : new_words } ) except ValueError : split_word = word . split ( "-" ) new_word_array = replace_word ( new_word_array , { word : clean_word_array ( split_word ) } ) elif word . isnumeric ( ) : new_words = split_up_digits ( word ) new_word_array = replace_word ( new_word_array , { word : new_words } ) else : try : new_words = split_up_digits ( str ( w2n . word_to_num ( word ) ) ) new_word_array = replace_word ( new_word_array , { word : new_words } ) except ValueError : continue if "'" in new_word_array : print ( new_word_array ) return new_word_array
Fix syntax, spelling, and grammar errors in word_array.
Fix syntax spelling and grammar errors in word_array .
"""
    Fix syntax, spelling, and grammar errors in word_array. Note, that this function is only designed to account for
    errors in the DREAM dataset.
    :param word_array: An array of words from the DREAM dataset.
    :return: a new word array with equivalent or improved grammar/spelling/syntax.
    """
a new word array with equivalent or improved grammar/spelling/syntax.
a new word array with equivalent or improved grammar / spelling / syntax .
word_array
An array of words from the DREAM dataset.
An array of words from the DREAM dataset .