def generate_errors_in_word(word):
    # take word from list
    # for each letter randomly double or tripple the letter, upper case it, or if a vowel swap for another random vowel
    transformations_for_ends = [
        upper_case_letter, 
        multiply_letter, 
        multiply_letter_upper, 
        leave_unchanged]
    all_transformations = [
        upper_case_letter, 
        multiply_letter, 
        substitute_vowel, 
        substitute_vowel_upper, 
        multiply_letter_upper]
    word_length = len(word)
    if word_length > 2 :
        
        new_word_letters = [
            apply_random_transformation(get_first_letter_of(word), transformations_for_ends),
            apply_random_transformation(get_last_letter_of(word), transformations_for_ends)
        ] 
        for letter in word[1:word_length-1]:
            new_letter = apply_random_transformation(letter, all_transformations)
            new_word_letters.insert(-1, new_letter)
        return "".join(new_word_letters)
    return "".join([apply_random_transformation(letter, transformations_for_ends) for letter in word])
Ejemplo n.º 2
0
def get_spellcheck_from_all_spellcheckers_for(word, fl_index):
    word = correct_case(word)
    key = get_first_letter_of(word) + get_last_letter_of(word) 
    repeating_checker = spellcheck_suggestions_for_repeating_letters(word, fl_index)
    vowels_checker = spellcheck_suggestions_for_vowels(word, fl_index)
    combined_checker = spellcheck_suggestions_for_repeating_and_vowels(word, fl_index)
    all_results = []
    map(lambda x : all_results.extend(x), [repeating_checker, vowels_checker, combined_checker])
    return all_results
Ejemplo n.º 3
0
def spellcheck_suggestions_for_repeating_and_vowels(word, fl_index):
    repeating_and_vowels_regex = generate_regex_to_correct_both_vowels_and_repeating_letters(word)
    key = get_first_letter_of(word) + get_last_letter_of(word)
    return [i for i in fl_index[key] if re.match(repeating_and_vowels_regex, i)]
Ejemplo n.º 4
0
def spellcheck_suggestions_for_vowels(word, fl_index):
    vowels_regex = generate_regex_to_correct_vowels
    key = get_first_letter_of(word) + get_last_letter_of(word)
    return [i for i in fl_index[key] if re.match(vowels_regex(word), i)]