Beispiel #1
0
 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)
Beispiel #5
0
    def testAfterExample(self):
        """Example: afterExample"""

        system = ASWS()
        soracle = ArcStandardWithSwapEagerOracle(system)
        transitions = oracle.buildStaticCorrectTransitions(
            afterExample[1], system, soracle)
        self.assertEqual(afterCorrect, transitions)
Beispiel #6
0
    def testChamberMusicExample(self):
        """Example: chamberMusicExample"""

        system = ArcStandard()
        soracle = ArcStandardStaticOracle(system)
        transitions = oracle.buildStaticCorrectTransitions(
            chamberMusicExample[1], system, soracle)
        self.assertEqual(chamberMusicCorrect, transitions)
Beispiel #7
0
    def testMsCollinsExample(self):
        """Example: msCollinsExample"""

        system = ArcStandard()
        soracle = ArcStandardStaticOracle(system)
        transitions = oracle.buildStaticCorrectTransitions(
            msCollinsExample[1], system, soracle)
        self.assertEqual(msCollinsCorrect, transitions)
Beispiel #8
0
    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)
Beispiel #9
0
    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)
Beispiel #10
0
    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)
Beispiel #11
0
    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))