Esempio n. 1
0
def learn_constraints(word_list):
    '''Learn the faithfulness and markedness constraints based on a word list'''
    for con in cons.faithfuls + cons.markeds:
        for paradigm in word_list:
            for derivative in paradigm.derivatives:
                for a in alignment.align_forms(paradigm.base, derivative.form):
                    if con.type == 'faithfulness':
                        score = con.func(paradigm.base, derivative.form, a)
                    elif con.type == 'markedness':
                        score = con.func(derivative.form)                    
                    con.scores[derivative.form.to_u()] = (score * (1 - derivative.probability))
Esempio n. 2
0
def test_wugs(wug_list):
    '''Get some wug plurals out of the constraints'''
    for wug in wug_list:
        for derivative in wug.derivatives:
            for a in alignment.align_forms(wug.base, derivative):
                for con in cons.faithfuls + cons.markeds:
                    if con.type == 'faithfulness':
                        score = con.func(wug.base, derivative, a)
                    elif con.type == 'markedness':
                        score = con.func(derivative)                
                    wug.scores[derivative.to_u()][con.func.__name__] = score * con.avg_score()