Ejemplo n.º 1
0
 def _advance_rule(self, rule, state, pair):
     trans = rule.fsa()._transitions[state]
     expected_pairs = sort_subsets(trans.keys(), self._subsets)
     for comppair in expected_pairs:
         if comppair.includes(pair, self._subsets):
             return rule.fsa().nextState(state, comppair)
     return None
Ejemplo n.º 2
0
 def _advance_rule(self, rule, state, pair):
     trans = rule.fsa()._transitions[state]
     expected_pairs = sort_subsets(trans.keys(), self._subsets)
     for comppair in expected_pairs:
         if comppair.includes(pair, self._subsets):
             return rule.fsa().nextState(state, comppair)
     return None
Ejemplo n.º 3
0
 def complete_fsa(self, fsa, fail_state=None):
     fsa = deepcopy(fsa)
     if fail_state is None:
         fail_state = fsa.add_state('Fail')
         fsa.insert('Fail', KimmoPair.make('@'), 'Fail')
     sorted_pairs = sort_subsets(self._pairs, self._subsets)
     for state in fsa.states():
         trans = fsa._transitions[state]
         for pair in self._pairs:
             if pair not in trans:
                 for sp in sorted_pairs:
                     if sp in trans and sp.includes(pair, self._subsets):
                         trans[pair] = trans[sp]
                         break
                 trans[pair] = [fail_state]
             if trans[pair] == []: trans[pair] = [fail_state]
     fsa._build_reverse_transitions()
     return fsa
Ejemplo n.º 4
0
 def complete_fsa(self, fsa, fail_state=None):
     fsa = deepcopy(fsa)
     if fail_state is None:
         fail_state = fsa.add_state('Fail')
         fsa.insert('Fail', KimmoPair.make('@'), 'Fail')
     sorted_pairs = sort_subsets(self._pairs, self._subsets)
     for state in fsa.states():
         trans = fsa._transitions[state]
         for pair in self._pairs:
             if pair not in trans:
                 for sp in sorted_pairs:
                     if sp in trans and sp.includes(pair, self._subsets):
                         trans[pair] = trans[sp]
                         break
                 trans[pair] = [fail_state]
             if trans[pair] == []: trans[pair] = [fail_state]
     fsa._build_reverse_transitions()
     return fsa