コード例 #1
0
ファイル: demo.py プロジェクト: SeaC0w/nlp_hw
def checkHarmonyAffix(word):
    vowels = Vowels(word)
    harm = []
    for i in range(len(vowels) - 1):
        ro = HasRoundness(vowels[i], vowels[i+1])
        fr = HasFrontness(vowels[i], vowels[i+1])
        if ro and fr:
            harm.append(0)
        elif ((ro and not fr) or (fr and not ro)):
            harm.append(1)
        else:
            harm.append(2)
    if (len(harm) == 0):
        check = 0
    else:
        check = max(harm)

    if check == 0:
        if word == '':
            print("No suffix, therefore perfect vowel harmony")
            return
        print("The suffix " + word + " has perfect vowel harmony")
    elif check == 1:
        print("The suffix " + word + " has partial vowel harmony")
    else:
        print("The suffix " + word + " breaks vowel harmony")
コード例 #2
0
ファイル: cityCorpus.py プロジェクト: SeaC0w/nlp_hw
def getHarmony(word):
    vowels = Vowels(word)
    harm = []
    for i in range(len(vowels) - 1):
        ro = HasRoundness(vowels[i], vowels[i + 1])
        fr = HasFrontness(vowels[i], vowels[i + 1])
        if ro and fr:
            harm.append(0)
        elif ((ro and not fr) or (fr and not ro)):
            harm.append(1)
        else:
            harm.append(2)
    if (len(harm) == 0):
        check = 0
    else:
        check = max(harm)
    return check
コード例 #3
0
def checkHarmony(word):
    vowels = Vowels(word)
    harm = []
    for i in range(len(vowels) - 1):
        ro = HasRoundness(vowels[i], vowels[i + 1])
        fr = HasFrontness(vowels[i], vowels[i + 1])
        if ro and fr:
            harm.append(0)
        elif ((ro and not fr) or (fr and not ro)):
            harm.append(1)
        else:
            harm.append(2)
    if (len(harm) == 0):
        check = 0
    else:
        check = max(harm)
    if check == 0:
        print(word + " has perfect vowel harmony")
    elif check == 1:
        print(word + " has partial vowel harmony")
    else:
        print(word + " breaks vowel harmony")