コード例 #1
0
ファイル: codes.py プロジェクト: domenicrosati/FAdo
    def trajToTransducer(traj, Sigma):
        """ Input Altering Tranducer corresponding to a Trajectory

        :param NFA traj: trajectory language
        :param set Sigma: alphabet
        :rtype: SFT"""
        t = SFT()
        t.Sigma = Sigma
        for s, sn in enumerate(traj.States):
            no = t.stateIndex((sn, False), True)
            yes = t.stateIndex((sn, True), True)
            if s in traj.Final:
                t.addFinal(yes)
            if s in traj.Initial:
                t.addInitial(no)
            for b in traj.delta.get(s, {}):
                for c in Sigma:
                    for st in traj.delta[s][b]:
                        fNo = t.stateIndex((traj.States[st], False), True)
                        fYes = t.stateIndex((traj.States[st], True), True)
                        if b == "0":
                            t.addTransition(no, c, c, fNo)
                            t.addTransition(yes, c, c, fYes)
                        if b == "1":
                            t.addTransition(no, Epsilon, c, fYes)
                            t.addTransition(yes, Epsilon, c, fYes)
        return t
コード例 #2
0
ファイル: fio.py プロジェクト: mebusy/codeLib
    def startTRANSSemRule(self, lst, context=None):
        """

            :param lst:
            :param context:"""
        if self.TRtype is None:
            new = SFT()
        elif self.TRtype == "GFT":
            new = GFT()
        else:
            raise common.TRError
        new.Sigma = self.alphabet
        new.Output = self.alphabetOut
        while self.states:
            x = self.states.pop()
            new.addState(x)
        while self.initials:
            x = self.initials.pop()
            new.addInitial(new.stateIndex(x))
        while self.finals:
            x = self.finals.pop()
            new.addFinal(new.stateIndex(x))
        while self.transitions:
            (x1, x2, x3, x4) = self.transitions.pop()
            new.addTransition(new.stateIndex(x1), x2, x3, new.stateIndex(x4))
        self.theList.append(new)
        self.initLocal()
コード例 #3
0
ファイル: fio.py プロジェクト: FakerKimg/regexor
    def startTRANSSemRule(self, lst, context=None):
            """

            :param lst:
            :param context:"""
            if self.TRtype is None:
                new = SFT()
            elif self.TRtype == "GFT":
                new = GFT()
            else: raise common.TRError
            new.Sigma = self.alphabet
            new.Output = self.alphabetOut
            while self.states:
                x = self.states.pop()
                new.addState(x)
            while self.initials:
                x = self.initials.pop()
                new.addInitial(new.stateIndex(x))
            while self.finals:
                x = self.finals.pop()
                new.addFinal(new.stateIndex(x))
            while self.transitions:
                (x1, x2, x3, x4) = self.transitions.pop()
                new.addTransition(new.stateIndex(x1), x2, x3, new.stateIndex(x4))
            self.theList.append(new)
            self.initLocal()