Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
    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
Esempio n. 4
0
    def test_count_syllables(self, orth, phon, count):
        sound_seq = SoundSequence(orth, phon)

        assert sound_seq.count_syllables() == count
Esempio n. 5
0
    def test_set_start_index(self, orth, phon, index):
        sound_seq = SoundSequence(orth, phon)
        sound_seq.set_start_index()

        assert sound_seq.index == index
Esempio n. 6
0
    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)
Esempio n. 7
0
    def test_next(self, orth, phon, index, phone):
        sound_seq = SoundSequence(orth, phon)
        sound_seq.index = index

        assert next(sound_seq).phone == phone