automaton
.compose
¶The (accessible part of the) composition of two transducers ($A_1$ and $A_2$).
Preconditions:
Postconditions:
See also:
import vcsn
ctx1 = vcsn.context("lat<lal<char(ab)>, lal<char(jk)>>, b")
ctx2 = vcsn.context("lat<lal<char(jk)>, lal<char(xy)>>, b")
a1 = ctx1.expression("(a|k)(a|j) + (b|k)*").automaton()
a1
a2 = ctx2.expression("(k|y)(k|x)*").automaton()
a2
The result of the composition has a useless state. Note that only the accessible part has been computed.
a1.compose(a2)
The composition of a "translator" from French to English with one from English to Spanish is analogous to the computation of the French to Spanish "translator".
%%file fr2en
chien|dot
chat|cat
ctx = vcsn.context("lat<lan<char>, lan<char>>, b")
fr_to_en = ctx.trie('fr2en')
fr_to_en
en_to_es = ctx.expression("dog|perro + cat|gato").automaton()
en_to_es
fr_to_es = fr_to_en.compose(en_to_es)
fr_to_es
This example follows the same path, but using letters that are strings.
import vcsn
ctx = vcsn.context("lat<lan<string>, lan<string>>, b")
ctx
%%file fr2en
'chien'|'dog'
'chat'|'cat'
'oiseau'|'bird'
'souris'|'mouse'
'souris'|'mice'
fr2en = ctx.trie('fr2en')
fr2en
%%file en2es
'dog'|'perro'
'cat'|'gato'
'mouse'|'ratón'
'mice'|'ratones'
en2es = ctx.trie('en2es')
en2es
fr2en.compose(en2es)