def merge(self, other: "Lemma") -> Optional["Lemma"]: """Merge another lemma into this one to form a compound.""" sound_seq_base = SoundSequence(self.orth, self.phon) phon, orth = other.get_stem() sound_seq_extra = SoundSequence(orth, phon) compound_orth = sound_seq_base.merge(sound_seq_extra) if compound_orth: return Lemma(compound_orth) return None
def test_create(self, orth, phon, phones, phones2graphs, syllables, stress_index): sound_seq = SoundSequence(orth, phon) sounds = [ Sound(phone, start_char, syllable, i == stress_index) for i, ( phone, start_char, syllable) in enumerate(zip(phones, phones2graphs, syllables)) ] assert sound_seq.orth == orth assert sound_seq.phon == phon assert sound_seq.sounds == sounds
def test_ends_with_schwa(self, orth, phon, ends_with_schwa): sound_seq = SoundSequence(orth, phon) assert sound_seq.ends_with_schwa() == ends_with_schwa
def test_count_syllables(self, orth, phon, count): sound_seq = SoundSequence(orth, phon) assert sound_seq.count_syllables() == count
def test_set_start_index(self, orth, phon, index): sound_seq = SoundSequence(orth, phon) sound_seq.set_start_index() assert sound_seq.index == index
def test_next_at_end_of_list(self, orth, phon, index): sound_seq = SoundSequence(orth, phon) sound_seq.index = index with pytest.raises(StopIteration): next(sound_seq)
def test_next(self, orth, phon, index, phone): sound_seq = SoundSequence(orth, phon) sound_seq.index = index assert next(sound_seq).phone == phone