11.9. twol.twbt module

Module for detailed handling basic transducers

Copyright 2015-2020, Kimmo Koskenniemi

This program is free software under Gnu GPL 3 or later


Find and print all sets of equivalent transition pairs.

bfst – a HfstIterableTransducer whose transition symbol pairs are analyzed

Sets of transition symbol pairs behaving identicaly are computed. The sets are printed if they contain more than one element.

twol.twbt.expanded_examples(TR, insyms, symbol_pair_set)[source]
twol.twbt.fsa_to_fst(FSA, separator='^')[source]

hfst.fsa_to_fst does the same


Returns a dict which gives the transition dict for each state

twol.twbt.fst_to_fsa(FST, separator='^')[source]

Converts FST into an FSA by joining input and output symbols with separator

twol.twbt.pairname(insym, outsym)[source]

Convert a pair of symbols into a single label

insym – input symbol as a string outsym – output symbol as a string

Returns a string notation of the pair, eg.

>>> pairname ('a', 'a')
>>> pairname('i','j')
twol.twbt.paths(TR, limit=30)[source]
twol.twbt.pp_paths(TR, heading, limit=30)[source]
twol.twbt.ppdef(XRC, name, displayed_formula)[source]
twol.twbt.ppfst(FST, print_equiv_classes=True, title='')[source]

Pretty-prints a HfstTransducer or a HfstIterableTransducer.

FST – the transducer to be pretty-printed print_equiv_classes – if True, then print also the equivalence classes title – an explicit additional title to be printed

If the transducer has a name, it is printed as a heading.

>>> twbt.ppfst(hfst.regex("a* [b:p|c] [c|b:p]"), True)
0 . -> 0  a ; -> 1  b:p ; 
1 . -> 2  b ; 
2 : 
Classes of equivalent symbols:
b:p c