Developers’ documentation¶
Module fsa¶
Finite State Automata
-
class
fsa4streams.fsa.FSA(structure, check_structure=True)[source]¶ A Finite State Automaton.
-
classmethod
make_empty(**kw)[source]¶ TODO doc: must call
check_structure()in the end
-
add_state(stateid, **kw)[source]¶ TODO doc
IMPORTANT: ‘target’ may not exist yet, so it not checked. Hence,
check_structure()should be called in the end.
-
allow_overlap¶
-
default_matcher¶
-
feed(event, timestamp=None)[source]¶ I ingest event, and I return a list of matching tokens.
A matching token is a token that has reached a final state, and can not further progress in the FSA.
If provided,
timestampmust be an integer greater or equal than all previous timestamps; the default value is the previous timestamp + 1. Timestamps are used to checkmax_durationconstraints.
-
classmethod
Module state¶
-
class
fsa4streams.state.State(fsa, stateid)[source]¶ A proxy object for a state in a FSA.
-
fsa¶
-
id¶
-
terminal¶ TODO doc
-
max_noise¶ TODO doc
-
max_total_noise¶ TODO doc
-
max_duration¶ TODO doc
-
max_total_duration¶ TODO doc
-
default_transition¶ TODO doc
-
transitions¶ TODO doc
-
check_structure(raises=True)[source]¶ Shortcut method to self.fsa.check_structure, useful for chaining them.
-
Module matcher¶
-
fsa4streams.matcher.DIRECTORY= a dict¶ It originally contains all the matchers contained in this module.
-
fsa4streams.matcher.match_multiple_choices(transition, event, _token, _fsa)[source]¶ The ‘multiple-choices’ matcher.
With this matcher, transition conditions must be lists of strings. It matches an event if that event is equal to one of the items of the list.
-
fsa4streams.matcher.match_regexp(transition, event, _token, _fsa)[source]¶ The ‘regexp’ matcher.
With this matcher, transition conditions are interpreted as regular expressions. Note that the whole event must match the regular expression (this is ensured by automatically prepending
^and appending$to the condition).