automaton
.compose
The (accessible part of the) composition of two transducers ($A_1$ and $A_2$).
Preconditions:
Postconditions:
See also:
In [5]:
import vcsn
ctx1 = vcsn.context("lat<lal<char(ab)>, lal<char(jk)>>, b")
ctx2 = vcsn.context("lat<lal<char(jk)>, lal<char(xy)>>, b")
In [6]:
a1 = ctx1.expression("(a|k)(a|j) + (b|k)*").automaton()
a1
Out[6]:
In [7]:
a2 = ctx2.expression("(k|y)(k|x)*").automaton()
a2
Out[7]:
The result of the composition has a useless state. Note that only the accessible part has been computed.
In [8]:
a1.compose(a2)
Out[8]:
In [9]:
%%file fr2en
chien|dot
chat|cat
In [10]:
ctx = vcsn.context("lat<lan<char>, lan<char>>, b")
fr_to_en = ctx.trie('fr2en')
fr_to_en
Out[10]:
In [11]:
en_to_es = ctx.expression("dog|perro + cat|gato").automaton()
en_to_es
Out[11]:
In [12]:
fr_to_es = fr_to_en.compose(en_to_es)
fr_to_es
Out[12]:
In [13]:
import vcsn
ctx = vcsn.context("lat<lan<string>, lan<string>>, b")
ctx
Out[13]:
In [14]:
%%file fr2en
'chien'|'dog'
'chat'|'cat'
'oiseau'|'bird'
'souris'|'mouse'
'souris'|'mice'
In [15]:
fr2en = ctx.trie('fr2en')
fr2en
Out[15]:
In [16]:
%%file en2es
'dog'|'perro'
'cat'|'gato'
'mouse'|'ratón'
'mice'|'ratones'
In [17]:
en2es = ctx.trie('en2es')
en2es
Out[17]:
In [18]:
fr2en.compose(en2es)
Out[18]: