예제 #1
0
def syllable_length(s, final=None):
    n = nucleus(s)
    r = rime(s)
    if len(n) > 1:
        b = "".join(base(ch) for ch in r)
        if final is True:
            if b in ["αι", "οι"]:
                return SHORT
            else:
                return LONG
        elif final is False:
            return LONG
        else:
            if b in ["αι", "οι"]:
                return UNKNOWN
            else:
                return LONG
    else:
        if iota_subscript(n):
            return LONG
        else:
            b = base(n)
            if b in "εο" or length(n) == SHORT:
                return SHORT
            elif b in "ηω" or length(n) == LONG:
                return LONG
            else:  # αιυ
                return UNKNOWN
예제 #2
0
def is_valid_consonant_cluster(b, c):
    s = base(b).lower() + ("".join(base(b2) for b2 in c)).lower()
    return s.startswith((
        "βδ", "βλ", "βρ",
        "γλ", "γν", "γρ",
        "δρ",
        "θλ", "θν", "θρ",
        "κλ", "κν", "κρ", "κτ",
        "μν",
        "πλ", "πν", "πρ", "πτ",
        "σβ", "σθ", "σκ", "σμ", "σπ", "στ", "σφ", "σχ", "στρ",
        "τρ",
        "φθ", "φλ", "φρ",
        "χλ", "χρ",
    ))
예제 #3
0
def add_necessary_breathing(w):
    s = syllabify(w)
    o, n, c = onset_nucleus_coda(s[0])
    if o == "" and not breathing(n):
        a = accent(n)
        if a:
            if len(n) == 2:
                n = n[0] + add_diacritic(add_diacritic(base(n[1]), SMOOTH), a)
            else:
                n = add_diacritic(add_diacritic(base(n), SMOOTH), a)
        else:
            if len(n) == 2:
                n = n[0] + add_diacritic(base(n[1]), SMOOTH)
            else:
                n = add_diacritic(base(n), SMOOTH)
        return o + n + c + "".join(s[1:])
    else:
        return w
예제 #4
0
def is_diphthong(chs):
    return base(chs[0]) + base(chs[1]) in [
        "αι", "ει", "οι", "υι",
        "αυ", "ευ", "ου", "ηυ",
    ] and not diaeresis(chs[1])
예제 #5
0
def is_vowel(ch):
    return ch == ACUTE or base(ch).lower() in "αεηιουω~"