def buildMPCs(self, tree): noSwapTrans = oracle.buildStaticCorrectTransitions( tree, self.__noSwap, self.__noSwapOracle) projectiveForest = tdatatypes.buildTreeFromTransitions( self.__noSwap, tree.nrOfTokens(), noSwapTrans) #print "projectiveForest", projectiveForest return self.__buildMPCsForTree(projectiveForest)
def testFranceExample(self): """Example: franceExample""" system = ArcHybrid() tree = tdatatypes.buildTreeFromTransitions( system, franceExample[1].nrOfTokens(), franceCorrect) self.assertEqual(tree, franceExample[1])
def testChangesExample(self): """Example: changesExample""" system = ArcHybrid() tree = tdatatypes.buildTreeFromTransitions( system, changesExample[1].nrOfTokens(), changesCorrect) self.assertEqual(tree, changesExample[1])
def testMsCollinsExample(self): """Example: msCollinsExample""" system = ArcHybrid() tree = tdatatypes.buildTreeFromTransitions( system, msCollinsExample[1].nrOfTokens(), msCollinsCorrect) self.assertEqual(tree, msCollinsExample[1])
def testOneWordExample(self): """Example: oneWordExample""" system = ArcHybrid() tree = tdatatypes.buildTreeFromTransitions( system, oneWordExample[1].nrOfTokens(), oneWordCorrect) self.assertEqual(tree, oneWordExample[1])
def testChamberMusicExample(self): """Example: chamberMusicExample""" system = ArcStandard() tree = tdatatypes.buildTreeFromTransitions( system, chamberMusicExample[1].nrOfTokens(), chamberMusicCorrect) self.assertEqual(tree, chamberMusicExample[1])
def testArcHybridWithLabels(self): system = ArcHybrid() labeler = MockLabeler(system, ["ROOT", "a", "b"]) correct = datatypes.Tree( [1, -1, 1, 1, 5, 6, 3, 6, 1], ["a", "ROOT", "a", "b", "b", "a", "a", "b", "a"]) soracle = ArcHybridStaticOracle(system, labeler) transitions = oracle.buildStaticCorrectTransitions( correct, labeler, soracle) predict = tdatatypes.buildTreeFromTransitions(labeler, correct.nrOfTokens(), transitions) self.assertEqual(predict, correct)
def testMimicSystemWithOneLabel_franceExample(self): correctTree = datatypes.Tree([-1, 0, 0, 0, 0, 0], ["ROOT", "a", "b", "c", "d", "e"]) correctTrans = [ ArcStandard.SHIFT, ArcStandard.SHIFT, ArcStandard.RIGHTARC, ArcStandard.SHIFT, ArcStandard.RIGHTARC, ArcStandard.SHIFT, ArcStandard.RIGHTARC, ArcStandard.SHIFT, ArcStandard.RIGHTARC, ArcStandard.SHIFT, ArcStandard.RIGHTARC, ArcStandard.RIGHTARC ] mocksystem = MockArcStandard() labeler = MockLabeler(mocksystem, ["ROOT", "a", "b", "c", "d", "e"]) soracle = ArcStandardStaticOracle(mocksystem, labeler) labtransitions = oracle.buildStaticCorrectTransitions( correctTree, labeler, soracle) # internal transitions self.assertEqual(mocksystem.transitions, correctTrans) # applying labeled transitions predTree = tdatatypes.buildTreeFromTransitions( labeler, correctTree.nrOfTokens(), labtransitions) self.assertEqual(str(predTree), str(correctTree))