ak9
ak9

Reputation: 51

Sequence Recognition using fsm in python

What is the best way to detect a sequence of characters in python?

I'm trying to use transitions package by Tal yarkoni for creating fsm's based on input sequences. Then i want to use the created fsms for new sequence recognition. I'm storing the created fsm in a dict with sequence number as key.

All the fsms from the dictionary should make transition as per input chars. The one which reaches end state is the required sequence and the function should return the key.

Problem is that there is no concept of end state in the transitions fsm model. Is it possible to do this using transitions package?

Upvotes: 0

Views: 191

Answers (1)

There is no concept of end state, but you can define a state 'end' on each fsm and check for it (see 'checking state' in the git readme), or you could add a 'on enter' reference on the 'end' state and that function will be called when the 'end' state is entered.

Haven't seen transitions before, looks very nice, I like being able to produce the diagrams.

Upvotes: 1

Related Questions