def check_spelling(p,q): pword = functions.return_syls_singleton(p.word) qword = functions.return_syls_singleton(q.word) tmp = pword.split('/') tmq = qword.split('/') p_syls = [item for item in tmp if len(item) not 0 if item is not ' '] q_syls = [item for item in tmq if len(item) not 0 if item is not ' '] # if the last syllable is a single letter, # we will use the second last + last instead: p_last_syllable = get_last_syl(p_syls) q_last_syllable = get_last_syl(q_syls) if (Levenshtein.distance(p_last_syllable, q_last_syllable) < 2): return True else: return False
def __init__(self, line, word): self.line_number = line self.word = word if word is not 'dummy_node': # split word into syllables and count them # more than 2 syllable --> need to call # double metaphone on the latter 2 syllables # of our word word_for_syl_counting = [] word_tmp = functions.return_syls_singleton(self.word).split('/') for item in word_tmp: if len(item) is not 0: if item is not ' ': word_for_syl_counting.append(item) self.symbol = None dmeta = fuzzy.DMetaphone() # a problem for words with many syllables self.symbol = dmeta(str(self.word))[0] # 0 = theta (i.e. thee is represented by 0) self.cmu_vector = "" self.tmp_vector = [] # this is a stack self.cmu = False self.cmu_rhyme_with_node = "" # inner rhyme pattern: self.rhymes_with_line_number = "" self.letter_designation = "" self.spelling_match = False self.symbol_match = False self.symbol_vector = [] self.nodebelow = None self.checked = False self.rhyme_info = [] self.eye_rhyme_vector = [] self.eye_rhyme = False self.rhyme_type = "" # inner rhyme pattern # outer rhyme pattern: self.rhyme_overall = "" # this is part the outer rhyme pattern self.cmu_vector2 = [] self.outer_letter = "" # other: self.vc_split = ""