Exemple #1
0
def ns_has_i_umlaut(ns: str, gs: str, np: str):
    """
    Checks if the nominative singular has an i-umlaut
    # >>> ns_has_i_umlaut("ketill", "ketils", "katlar")
    # True

    >>> ns_has_i_umlaut("armr", "arms", "armar")
    False

    >>> ns_has_i_umlaut("mór", "mós", "móar")
    False

    >>> ns_has_i_umlaut("hirðir", "hirðis", "hirðar")
    False

    >>> ns_has_i_umlaut("söngr", "söngs", "söngvar")
    False

    >>> ns_has_i_umlaut("gestr", "gests", "gestir")
    False

    >>> ns_has_i_umlaut("staðr", "staðar", "staðir")
    False

    :param ns:
    :param gs:
    :param np:
    :return:
    """

    ns_syl = s.syllabify_ssp(ns)
    gs_syl = s.syllabify_ssp(gs)
    np_syl = s.syllabify_ssp(np)
    s_ns_syl = [Syllable(syl, VOWELS, CONSONANTS) for syl in ns_syl]
    s_gs_syl = [Syllable(syl, VOWELS, CONSONANTS) for syl in gs_syl]
    s_np_syl = [Syllable(syl, VOWELS, CONSONANTS) for syl in np_syl]
    if len(gs_syl) >= 2 and s_gs_syl[-1].nucleus[0] == "i":
        if len(ns_syl) >= 2:
            vowel = s_ns_syl[-2].nucleus[0]
        else:
            vowel = s_ns_syl[-1].nucleus[0]
        return vowel in BACK_TO_FRONT_VOWELS and s_gs_syl[-2].nucleus[
            0] == BACK_TO_FRONT_VOWELS[vowel]

    if len(np_syl) >= 2 and s_np_syl[-1].nucleus[0] == "i":
        if len(ns_syl) >= 2:
            vowel = s_ns_syl[-2].nucleus[0]
        else:
            vowel = s_ns_syl[-1].nucleus[0]
        return vowel in BACK_TO_FRONT_VOWELS and s_np_syl[-2].nucleus[
            0] in BACK_TO_FRONT_VOWELS[vowel]

    return False
Exemple #2
0
    def classify(self):

        signature = [
            "".join(Syllable(self.s_sng[0], VOWELS, CONSONANTS).nucleus),
            "".join(Syllable(self.s_sfg3en[0], VOWELS, CONSONANTS).nucleus),
            "".join(Syllable(self.s_sfg3et[0], VOWELS, CONSONANTS).nucleus),
            "".join(Syllable(self.s_sfg3ft[0], VOWELS, CONSONANTS).nucleus),
            "".join(Syllable(self.s_stgken[0], VOWELS, CONSONANTS).nucleus)
        ]
        if signature == ['í', 'í', 'ei', 'i', 'i']:
            self.subclass = 1
        elif signature == ['ó', 'ý', 'au', 'u', 'o']:
            self.subclass = 2
        elif signature == ['e', 'e', 'a', 'u', 'o']:
            self.subclass = 3
        elif signature == ['e', 'e', 'a', 'á', 'o']:
            self.subclass = 4
        elif signature == ['e', 'e', 'a', 'á', 'e']:
            self.subclass = 5
        elif signature == ['a', 'e', 'ó', 'ó', 'a']:
            self.subclass = 6
        elif signature == ['á', 'æ', 'é', 'é', 'á']:
            self.subclass = 7
Exemple #3
0
def has_u_umlaut(word: str) -> bool:
    """
    Does the word have an u-umlaut?

    >>> has_u_umlaut("höfn")
    True

    >>> has_u_umlaut("börnum")
    True

    >>> has_u_umlaut("barn")
    False

    :param word: Old Norse word
    :return: has an u-umlaut occurred?
    """
    word_syl = s.syllabify_ssp(word)
    s_word_syl = [Syllable(syl, VOWELS, CONSONANTS) for syl in word_syl]

    if len(s_word_syl) == 1 and s_word_syl[-1].nucleus[0] in ["ö", "ǫ"]:
        return True
    elif len(s_word_syl) >= 2 and s_word_syl[-1].nucleus[0] == "u":
        return s_word_syl[-2].nucleus[0] in ["ö", "ǫ"]
    return False
Exemple #4
0
def add_t_ending(stem: str) -> str:
    """

    >>> add_t_ending("batt")
    'bazt'
    >>> add_t_ending("gat")
    'gazt'
    >>> add_t_ending("varð")
    'vart'
    >>> add_t_ending("hélt")
    'hélt'
    >>> add_t_ending("réð")
    'rétt'
    >>> add_t_ending("laust")
    'laust'
    >>> add_t_ending("sá")
    'sátt'

    :param stem:
    :return:
    """
    s_stem = s.syllabify_ssp(stem.lower())
    last_syllable = Syllable(s_stem[-1], VOWELS, CONSONANTS)
    return "".join(s_stem[:-1]) + add_t_ending_to_syllable(last_syllable.text)
Exemple #5
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
Exemple #6
0
def add_r_ending(stem: str) -> str:
    """
    Adds an -r ending to an Old Norse noun.

    >>> add_r_ending("arm")
    'armr'

    >>> add_r_ending("ás")
    'áss'

    >>> add_r_ending("stól")
    'stóll'

    >>> add_r_ending("jökul")
    'jökull'

    >>> add_r_ending("stein")
    'steinn'

    >>> add_r_ending('mikil')
    'mikill'

    >>> add_r_ending('sæl')
    'sæll'

    >>> add_r_ending('litil')
    'litill'

    >>> add_r_ending('vænn')
    'vænn'

    >>> add_r_ending('lauss')
    'lauss'

    >>> add_r_ending("vin")
    'vinr'

    >>> add_r_ending("sel")
    'selr'

    >>> add_r_ending('fagr')
    'fagr'

    >>> add_r_ending('vitr')
    'vitr'

    >>> add_r_ending('vetr')
    'vetr'

    >>> add_r_ending('akr')
    'akr'

    >>> add_r_ending('Björn')
    'björn'

    >>> add_r_ending('þurs')
    'þurs'

    >>> add_r_ending('karl')
    'karl'

    >>> add_r_ending('hrafn')
    'hrafn'

    :param stem:
    :return:
    """
    s_stem = s.syllabify_ssp(stem.lower())
    n_stem = len(s_stem)
    last_syllable = Syllable(s_stem[-1], VOWELS, CONSONANTS)
    return "".join(s_stem[:-1]) + add_r_ending_to_syllable(
        last_syllable.text, n_stem == 1)
Exemple #7
0
 def test_syllable2(self):
     sylla2 = Syllable("gangr", ["a"], ["g", "n", "r"])
     self.assertLessEqual(sylla2.onset, ["g"])
     self.assertLessEqual(sylla2.nucleus, ["a"])
     self.assertLessEqual(sylla2.coda, ["n", "g", "r"])
Exemple #8
0
 def test_syllable1(self):
     sylla1 = Syllable("armr", ["a"], ["r", "m"])
     self.assertListEqual(sylla1.nucleus, ["a"])
     self.assertLessEqual(sylla1.onset, [])
     self.assertLessEqual(sylla1.coda, ["r", "m", "r"])