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

from SciPyFST import fst, fstUtils
brainMealy = fst(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(fstUtils.toMdTable(brainMealy)))
Input \ State S0 S1
0 S1/0 S1/0
1 S0/0 S0/1
display(graphviz.Source(fstUtils.toDot(brainMealy)))

brainMealy

Convert Mealy to Moore FST

brainMoore = brainMealy.asMoore()
display(Markdown(fstUtils.toMdTable(brainMoore)))
display(graphviz.Source(fstUtils.toDot(brainMoore)))
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 = fst(states_03, initState_03, inAlphabet_03,
    outAlphabet_03, transitionFunction_03, outputFunction_03)
display(graphviz.Source(fstUtils.toDot(fstWithUnreachableStates, 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.4.tar.gz (9.3 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.4-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: SciPyFST-0.0.4.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for SciPyFST-0.0.4.tar.gz
Algorithm Hash digest
SHA256 c3526eccc76fed1b3baeb7969704d6c9a6bd478902b9a8d228ac548cee2446c4
MD5 2892313f775b332c3b8f66beab64b4a2
BLAKE2b-256 1ac4cecd76707b255db020638e1e039589ddfbf1c8c3f96350284d69edc03d9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: SciPyFST-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for SciPyFST-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6a10e5837932fd85b95571c01272a921a6e01446a2f20fec705d394b9d69298c
MD5 94249e5d02b0b125989c9273d2312c25
BLAKE2b-256 1a3fd9581483630398bbd11e2b89cecafea86bb7831c2d14274aececd9d6a3ab

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