예제 #1
0
 def test_predict(self):
     A = {
         'a': {
             'g': 1.0,
             'j': 1.0
         },
         'g': {
             'f': 1.0
         },
         'f': {
             'a': 0.5,
             'k': 0.5
         },
         'k': {
             'j': 0.5
         },
         'j': {
             'f': 1.0
         },
         'r': {
             'u': 1.0
         },
         'u': {
             'v': 1.0
         }
     }
     ss = ('f', 'b')
     anss = ([['a', 'j'], ['a', 'g']], None)
     for s, ans in zip(ss, anss):
         res = predict(2, 2, s, A)
         self.assertEqual(res, ans, None)
예제 #2
0
def testIndivChainCorrection(chains, A):
    correctCount = 0
    for chain in chains:
        chainCorrect = 0
        for i, p in enumerate(chain):
            partCorrect = 0
            m = len(chain) - (i + 1)
            if m == 0:
                break
            pChains = predict(m, numberOfChain, p, A)
예제 #3
0
 def test_predict(self):
     A = {'a': {'g': 1.0, 'j': 1.0},
          'g': {'f': 1.0},
          'f': {'a': 0.5, 'k': 0.5},
          'k': {'j': 0.5},
          'j': {'f': 1.0},
          'r': {'u': 1.0},
          'u': {'v': 1.0}}
     ss = ('f', 'b')
     anss = ([['a', 'j'], ['a', 'g']], None)
     for s, ans in zip(ss, anss):
         res = predict(2, 2, s, A)
         self.assertEqual(res, ans, None)
예제 #4
0
def testWholeChainCorrection(chains, A):
    correctCount = 0
    for chain in chains:
        p1 = chain[0]
        m = len(chain) - 1
        pChains = predict(m, numberOfChain, p1, A)
        flag = False
        for pChain in pChains:
            if len(pChain) == len(chain):
                flag = True
                for i in range(1, len(pChain)):
                    if pChain[i] != chain[i]:
                        flag = False
                        break
        if flag:
            correctCount += 1
            print "Chain %s correct" % chain
    print "Correct count : %d" % correctCount
    print "Total count : %d" % len(chains)
    print "Rate: %f" % float(correctCount) / float(len(chains))