def keep_phonetic_match(cls, word, query): word = replace_special_leading_sounds(word) query = replace_special_leading_sounds(query) word_has_leading_vowel = has_leading_vowel(word) query_has_leading_vowel = has_leading_vowel(query) word_first_consonant = first_consonants(word) query_first_consonant = first_consonants(query) query_first_vowels = first_vowels(query, query_has_leading_vowel) word_first_vowels = first_vowels(word, word_has_leading_vowel) if query_has_leading_vowel: query_sound = query_first_vowels + query_first_consonant else: query_sound = query_first_consonant + query_first_vowels if word_has_leading_vowel: word_sound = word_first_vowels + word_first_consonant else: word_sound = word_first_consonant + word_first_vowels if word_sound == query_sound: return True return False
def test_can_extract_o(): assert_that(first_vowels('GOLDSTREAM'), equal_to('O'))
def test_can_extract_ou(): assert_that(first_vowels('CLOUDSIDE'), equal_to('OU'))
def test_resists_no_vowel(): assert_that(first_vowels('KCH'), equal_to(''))