Exemplo n.º 1
0
 def test_syllable_length_2(self):
     ont.o.length = ont.Length.long
     word = [ont.n, ont.o, ont.t.lengthen()]  # nótt
     syllabified_word = [word]
     lengths = []
     for syllable in syllabified_word:
         lengths.append(ont.measure_old_norse_syllable(syllable))
     self.assertListEqual(lengths, [ut.Length.overlong])
Exemplo n.º 2
0
 def test_syllable_length_1(self):
     syllabifier = Syllabifier(language="old_norse_ipa")
     word = [ont.a, ont.s, ont.g, ont.a, ont.r, ont.dh, ont.r]  # asgarðr (normally it is ásgarðr)
     syllabified_word = syllabifier.syllabify_phonemes(word)
     lengths = []
     for syllable in syllabified_word:
         lengths.append(ont.measure_old_norse_syllable(syllable))
     self.assertListEqual(lengths, [ut.Length.short, ut.Length.long])
Exemplo n.º 3
0
 def test_syllable_length_2(self):
     ont.o.length = ont.Length.long
     word = [ont.n, ont.o, ont.t.lengthen()]  # nótt
     syllabified_word = [word]
     lengths = []
     for syllable in syllabified_word:
         lengths.append(ont.measure_old_norse_syllable(syllable))
     self.assertListEqual(lengths, [ut.Length.overlong])
Exemplo n.º 4
0
 def test_syllable_length_1(self):
     syllabifier = Syllabifier(language="old_norse_ipa")
     word = [ont.a, ont.s, ont.g, ont.a, ont.r, ont.dh, ont.r]  # asgarðr (normally it is ásgarðr)
     syllabified_word = syllabifier.syllabify_phonemes(word)
     lengths = []
     for syllable in syllabified_word:
         lengths.append(ont.measure_old_norse_syllable(syllable))
     self.assertListEqual(lengths, [ut.Length.short, ut.Length.long])
Exemplo n.º 5
0
Arquivo: verse.py Projeto: cltk/cltk
    def parse_word_with(self, poetry_tools: PoetryTools):
        """
        Compute the phonetic transcription of the word with IPA representation
        Compute the syllables of the word
        Compute the length of each syllable
        Compute if a syllable is stress of noe
        Compute the POS category the word is in

        :param poetry_tools: instance of PoetryTools
        :return:
        """
        phonemes = poetry_tools.tr.text_to_phonemes(self.text)
        self.syl = poetry_tools.syllabifier.syllabify_phonemes(phonemes)
        for i, syllable in enumerate(self.syl):
            self.ipa_transcription.append([])
            syl_len = measure_old_norse_syllable(syllable).value
            syl_stress = 1 if i == 0 else 0

            self.length.append(syl_len)
            self.stress.append(syl_stress)
            for c in syllable:
                self.ipa_transcription[i].append(c.ipar)
Exemplo n.º 6
0
    def parse_word_with(self, poetry_tools: PoetryTools):
        """
        Compute the phonetic transcription of the word with IPA representation
        Compute the syllables of the word
        Compute the length of each syllable
        Compute if a syllable is stress of noe
        Compute the POS category the word is in

        :param poetry_tools: instance of PoetryTools
        :return:
        """
        phonemes = poetry_tools.tr.text_to_phonemes(self.text)
        self.syl = poetry_tools.syllabifier.syllabify_phonemes(phonemes)
        for i, syllable in enumerate(self.syl):
            self.ipa_transcription.append([])
            syl_len = measure_old_norse_syllable(syllable).value
            syl_stress = 1 if i == 0 else 0

            self.length.append(syl_len)
            self.stress.append(syl_stress)
            for c in syllable:
                self.ipa_transcription[i].append(c.ipar)
Exemplo n.º 7
0
    def classify(self):
        if self.sng in ["segja", "þegja"]:
            self.subclass = 4
        elif self.sng in ["vilja", "gera"]:
            self.subclass = 3
        elif self.sng in ["spá"]:
            self.subclass = 2
        elif self.sng and self.sfg3et and self.stgken:
            if self.sfg3et.endswith("aði"):
                self.subclass = 1

            elif not "".join(
                    Syllable(
                        self.s_sng[0], VOWELS,
                        CONSONANTS).nucleus) in BACK_TO_FRONT_VOWELS.values():
                self.subclass = 4
            else:
                stem_length = measure_old_norse_syllable(self.sp_sng[0])
                if stem_length == Length.long or stem_length == Length.overlong:
                    self.subclass = 2
                elif stem_length == Length.short:
                    self.subclass = 3
                else:
                    self.subclass = 5
Exemplo n.º 8
0
 def test_syllable_length_3(self):
     word = [ont.t, ont.t]  # tt
     lengths = []
     for syllable in [word]:
         lengths.append(ont.measure_old_norse_syllable(syllable))
     self.assertListEqual(lengths, [None])
Exemplo n.º 9
0
 def test_syllable_length_3(self):
     word = [ont.t, ont.t]  # tt
     lengths = []
     for syllable in [word]:
         lengths.append(ont.measure_old_norse_syllable(syllable))
     self.assertListEqual(lengths, [None])