A finite state machine modeler that allows you to generate output for procedures such as text generation.
Install using the provided setup.py.
$ cd path/to/main/folder
$ pip install .
- Create a list of States that you will use in your Machination. All your States should be uniquely named. Return None if your State has no State to go to, or if there is a condition that cannot be satisfied.
from machination.stringbuild import StringState
st_one = StringState("one_name", one_function, "one text")
- Create a Machination from the List of States, along with the starting State.
from machination.stringbuild import StringMachination
mach = StringMachination(states, st_one)
- Run the Machination on given data. Here we are running it on a single piece of data where the 'one_name' state gets the argument of 'cats.' An optional argument was passed where if we were to visit another state, we would concatenate the strings with a space instead of nothing at all.
mach.run({
'one_name': 'cats'
}, " ")
Testing requires mock, nose and (optional) coverage libraries. nosetests should work just fine.