Skip to main content

The package perform simple operations on FST (Finite-state transducer) and visualize results obtained

Project description

SciPyFST

The package perform simple operations on FST (Finite-state transducer) and visualize results obtained

Install

It can be installed from pypi.org/project/SciPyFST/

pip install SciPyFST

Development (branch main) version is available from test.pypi.org/project/SciPyFST/

pip install -i https://test.pypi.org/simple/ SciPyFST

Usage

Create Mealy FST

brainMealy = SciPyFST(initState='S0',
    transitionFunction=[['S0',0,'S1'],['S0',1,'S0'],['S1',0,'S1'],['S1',1,'S0']],
    outputFunction=[['S0',0,0],['S0',1,0],['S1',0,0],['S1',1,1]])

Visualize result as MarkDown table or Dot graph

display(Markdown(brainMealy.toMdTable()))
Input \ State S0 S1
0 S1/0 S1/0
1 S0/0 S0/1
display(graphviz.Source(brainMealy.toDot()))

brainMealy

Convert Mealy to Moore FST

brainMoore = brainMealy.asMoore()
display(Markdown(brainMoore.toMdTable()))
display(graphviz.Source(brainMoore.toDot()))
Input \ State 0/- 1/0 2/0 3/1
0 1 1 1 1
1 2 3 2 2

brainMoore

Visualize unreachable states

# FST with unreachoble states
states_03 = ['A0','A1','A2','A3']
initState_03 = 'A0'
inAlphabet_03 = ['x1','x2']
outAlphabet_03 = ['y1','y2','y3','y4','y5']
# transitionFunction [ [State, inAlphabet, nextState], ...]
transitionFunction_03 = [ \
    ['A0','x1','A2'], ['A0','x2','A3'], \
    ['A1','x1','A2'], ['A1','x2','A3'], \
    ['A2','x1','A0'], ['A2','x2','A3'], \
    ['A3','x1','A2'], ['A3','x2','A3'], \
]
# outputFunction Mealy [ [State, inAlphabet, outAlphabet], ...]
outputFunction_03 = [ \
    ['A0','x1','y1'], ['A0','x2','y1'], \
    ['A1','x1','y2'], ['A1','x2','y2'], \
    ['A2','x1','y3'], ['A2','x2','y1'], \
    ['A3','x1','y3'], ['A3','x2','y2'] \
]
fstWithUnreachableStates = SciPyFST(states_03, initState_03, inAlphabet_03,
    outAlphabet_03, transitionFunction_03, outputFunction_03)
display(graphviz.Source(fstWithUnreachableStates.toDot(colorOfUnreachableStates='tomato')))

brainMoore

More examples

nbviewer.org/github/MorriganR/SciPyFST/blob/main/examples/README.ipynb

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SciPyFST-0.0.3.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SciPyFST-0.0.3-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file SciPyFST-0.0.3.tar.gz.

File metadata

  • Download URL: SciPyFST-0.0.3.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for SciPyFST-0.0.3.tar.gz
Algorithm Hash digest
SHA256 6e0f95c6f3ec0619bfb5ce10de22d1c50a42a6c36c620827b566c824047133f8
MD5 6d62d9cf7d7dd06aa54eaf5298089ddc
BLAKE2b-256 2d7f2581b5765e71911b6b1dd292ee5a206c9afeda9203bb66ea571f7b2000ae

See more details on using hashes here.

File details

Details for the file SciPyFST-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: SciPyFST-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for SciPyFST-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 13478238acadd09e5f18566000b03ed81657952478b623ace94aea0e5e89a4a8
MD5 d4cfb0bc8626f1df97e69229bd6deaed
BLAKE2b-256 977f6fed209c8af563196d81c7f146e9a0bab427d4d62431147126eff4baa1b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page