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 testChangesExample(self): """Example: changesExample""" system = ArcHybrid() soracle = ArcHybridStaticOracle(system) transitions = oracle.buildStaticCorrectTransitions( changesExample[1], system, soracle) self.assertEqual(changesCorrect, transitions)
def testOneWordExample(self): """Example: oneWordExample""" system = ArcHybrid() soracle = ArcHybridStaticOracle(system) transitions = oracle.buildStaticCorrectTransitions( oneWordExample[1], system, soracle) self.assertEqual(oneWordCorrect, transitions)
def testFranceExample(self): """Example: franceExample""" system = ArcHybrid() soracle = ArcHybridStaticOracle(system) transitions = oracle.buildStaticCorrectTransitions( franceExample[1], system, soracle) self.assertEqual(franceCorrect, transitions)
def testAfterExample(self): """Example: afterExample""" system = ASWS() soracle = ArcStandardWithSwapEagerOracle(system) transitions = oracle.buildStaticCorrectTransitions( afterExample[1], system, soracle) self.assertEqual(afterCorrect, transitions)
def testChamberMusicExample(self): """Example: chamberMusicExample""" system = ArcStandard() soracle = ArcStandardStaticOracle(system) transitions = oracle.buildStaticCorrectTransitions( chamberMusicExample[1], system, soracle) self.assertEqual(chamberMusicCorrect, transitions)
def testMsCollinsExample(self): """Example: msCollinsExample""" system = ArcStandard() soracle = ArcStandardStaticOracle(system) transitions = oracle.buildStaticCorrectTransitions( msCollinsExample[1], system, soracle) self.assertEqual(msCollinsCorrect, transitions)
def testAfterExample(self): """Example: afterExample""" afterLazyCorrect = [ ASWS.SHIFT, ASWS.SHIFT, ASWS.LEFTARC, ASWS.SHIFT, ASWS.SHIFT, ASWS.SHIFT, ASWS.LEFTARC, ASWS.SWAP, ASWS.SHIFT, ASWS.SHIFT, ASWS.LEFTARC, ASWS.RIGHTARC, ASWS.RIGHTARC, ASWS.RIGHTARC ] system = ASWS() soracle = ArcStandardWithSwapLazyOracle(system) transitions = oracle.buildStaticCorrectTransitions( afterExample[1], system, soracle) self.assertEqual(afterLazyCorrect, transitions)
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 testLetterExample(self): """Example: letterExample""" system = ASWS() lazyoracle = ArcStandardWithSwapLazyOracle(system) letterCorrect = [ ASWS.SHIFT, ASWS.SHIFT, ASWS.SHIFT, ASWS.RIGHTARC, ASWS.SWAP, ASWS.SHIFT, ASWS.SHIFT, ASWS.SHIFT, ASWS.SHIFT, ASWS.LEFTARC, ASWS.RIGHTARC, ASWS.SWAP, ASWS.SHIFT, ASWS.SHIFT, ASWS.LEFTARC, ASWS.RIGHTARC, ASWS.RIGHTARC, ASWS.SHIFT, ASWS.RIGHTARC, ASWS.RIGHTARC ] lazyTransitions = oracle.buildStaticCorrectTransitions( letterExample[1], system, lazyoracle) self.assertEqual(lazyTransitions, letterCorrect)
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))