Esempio n. 1
0
 def syllabify(self):
     """
     Syllables may play a role in verse classification.
     """
     if len(self.long_lines) == 0:
         logger.error("No text was imported")
         self.syllabified_text = []
     else:
         syllabifier = Syllabifier(language="old_norse", break_geminants=True)
         syllabified_text = []
         for i, line in enumerate(self.long_lines):
             syllabified_text.append([])
             for j, viisuordh in enumerate(line):
                 syllabified_text[i].append([])
                 words = []
                 for word in tokenize_old_norse_words(viisuordh):
                     # punctuation is not necessary here
                     word = word.replace(",", "")
                     word = word.replace(".", "")
                     word = word.replace(";", "")
                     word = word.replace("!", "")
                     word = word.replace("?", "")
                     word = word.replace("-", "")
                     word = word.replace(":", "")
                     if word != '':
                         words.append(syllabifier.syllabify(word.lower()))
                 syllabified_text[i][j].append(words)
         self.syllabified_text = syllabified_text
Esempio n. 2
0
    def syllabify(self, syllabifier):
        """

        :param syllabifier:
        :return:
        """
        for viisuordh in tokenize_old_norse_words(self.text):
            word = normalize(viisuordh)
            if word:
                self.syllabified.append(syllabifier.syllabify(word))
Esempio n. 3
0
 def __init__(self, text):
     self.text = text
     self.tokenized_text = tokenize_old_norse_words(text)
     self.first_sounds = []
     self.syllabified = []
     self.transcribed = []
     self.alliterations = []
     self.phonological_features_text = []
     self.n_alliterations = 0
     self.syllabified_phonological_features_text = []
Esempio n. 4
0
    def syllabify(self, syllabifier):
        """

        :param syllabifier:
        :return:
        """
        for viisuordh in tokenize_old_norse_words(self.text):
            word = normalize(viisuordh)
            if word:
                self.syllabified.append(syllabifier.syllabify(word))
Esempio n. 5
0
 def __init__(self, text):
     self.text = text
     self.tokenized_text = tokenize_old_norse_words(text)
     self.short_lines = None
     self.first_sounds = []
     self.syllabified = []
     self.transcribed = []
     self.alliterations = []
     self.phonological_features_text = []
     self.n_alliterations = 0
     self.syllabified_phonological_features_text = []
Esempio n. 6
0
    def test_syllabification_old_norse(self):
        old_norse_syllabifier = Syllabifier(language="old_norse", break_geminants=True)
        text = "Gefjun dró frá Gylfa glöð djúpröðul óðla, svá at af rennirauknum rauk, Danmarkar auka. Báru öxn ok átta" \
               " ennitungl, þars gengu fyrir vineyjar víðri valrauf, fjögur höfuð."
        words = tokenize_old_norse_words(text)
        syllabified_words = [old_norse_syllabifier.legal_onsets(old_norse_syllabifier.syllabify_SSP(word.lower()), invalid_onsets)
                             for word in words if word not in ",."]

        target = [['gef', 'jun'], ['dró'], ['frá'], ['gyl', 'fa'], ['glöð'], ['djúp', 'rö', 'ðul'], ['óðl', 'a'],
                  ['svá'], ['at'], ['af'], ['ren', 'ni', 'rauk', 'num'], ['rauk'], ['dan', 'mar', 'kar'], ['auk', 'a'],
                  ['bár', 'u'], ['öxn'], ['ok'], ['át', 'ta'], ['en', 'ni', 'tungl'], ['þars'], ['geng', 'u'],  ['fy', 'rir'],
                  ['vi', 'ney', 'jar'], ['víðr', 'i'], ['val', 'rauf'], ['fjö', 'gur'], ['hö', 'fuð']]
        self.assertListEqual(syllabified_words, target)
Esempio n. 7
0
    def to_phonetics(self, transcriber):
        """
        Phontic transcription of the ShortLine instances.
        :param transcriber:
        :return:
        """
        for viisuordh in tokenize_old_norse_words(self.text):
            word = normalize(viisuordh)
            if word != "":
                transcribed_word = transcriber.main(word)
                pfl = transcriber.first_process(word)

                self.transcribed.append(transcribed_word)
                self.phonological_features_text.append(pfl)
        self.get_first_sounds()
Esempio n. 8
0
    def to_phonetics(self, transcriber):
        """
        Phontic transcription of the ShortLine instances.
        :param transcriber:
        :return:
        """
        for viisuordh in tokenize_old_norse_words(self.text):
            word = normalize(viisuordh)
            if word:
                transcribed_word = transcriber.text_to_phonetic_representation(word)
                pfl = transcriber.text_to_phonemes(word)

                self.transcribed.append(transcribed_word)
                self.phonological_features_text.append(pfl)
        self.get_first_sounds()