Exemplo n.º 1
0
    def test_cond_prop(self):
        hmm = HMM(UDDataSet("data/en-ud-train.conllu"))

        cprob = hmm.cond_prob(4, 3, 7)
        self.assertAlmostEqual(1.00, sum([np.exp(i) for i in cprob]))

        often = hmm.dataset.lookup_word("often")
        adj = hmm.dataset.lookup_pos("ADJ")
        propn = hmm.dataset.lookup_pos("PROPN")
        cprob = hmm.cond_prob(often, adj, propn)
        self.assertAlmostEqual(1.00, sum([np.exp(i) for i in cprob]))
Exemplo n.º 2
0
    def test_error_cond_prop(self):
        hmm = HMM(UDDataSet("data/en-ud-train.conllu"))

        cprob = hmm.cond_prob(121, 4, 16)
        self.assertAlmostEqual(1.00, sum([np.exp(i) for i in cprob]))