automaton.letterize()

Split the transition labels into letters.

Preconditions:

  • None

Postconditions:

  • the output transitions are atomic, meaning that they are composed of one letter (as viewed by the labelset). The labelset is adapted to provide this guarantee.

See also:

Examples


In [1]:
import vcsn
ctx = vcsn.context("law_char, b")
ctx


Out[1]:
$\{\ldots\}^*\rightarrow\mathbb{B}$

In [2]:
a = ctx.expression("(cat)+(dog)*").standard()
a


Out[2]:
%3 I0 0 0 I0->0 F0 F1 F3 0->F0 1 1 0->1 cat 3 3 0->3 dog 1->F1 3->F3 3->3 dog

In [3]:
al = a.letterize()
al


Out[3]:
%3 I0 0 0 I0->0 F0 F1 F2 0->F0 3 3 0->3 c 5 5 0->5 d 1 1 1->F1 2 2 2->F2 7 7 2->7 d 4 4 3->4 a 4->1 t 6 6 5->6 o 6->2 g 8 8 7->8 o 8->2 g

In [4]:
al.context()


Out[4]:
$(\{a, c, d, g, o, t\})^?\rightarrow\mathbb{B}$

Note that here, the transitions are no longer words (law) but instead letters (nullableset<lal_char>).


In [5]:
ctx_t = vcsn.context("lat<law_char, law_char, lal_char>, z")

In [6]:
b = ctx_t.expression(r"(<2>'cat,dog,c')*+'\e,b,d'").derived_term()
b


Out[6]:
%3 I0 0 ε|b|d+(⟨2⟩(cat|dog|c))* I0->0 F0 F1 F2 0->F0 1 ε 0->1 ε|b|d 2 (⟨2⟩(cat|dog|c))* 0->2 ⟨2⟩cat|dog|c 1->F1 2->F2 2->2 ⟨2⟩cat|dog|c

In [7]:
bl = b.letterize()
bl


Out[7]:
%3 I0 0 0 I0->0 F0 F1 F2 0->F0 1 1 0->1 ε|b|d 3 3 0->3 ⟨2⟩c|d|c 1->F1 2 2 2->F2 5 5 2->5 ⟨2⟩c|d|c 4 4 3->4 a|o|ε 4->2 t|g|ε 6 6 5->6 a|o|ε 6->2 t|g|ε

In [8]:
bl.context()


Out[8]:
$(\{a, c, t\})^? \times (\{b, d, g, o\})^? \times (\{c, d\})^?\rightarrow\mathbb{Z}$

Here, all three labelsets have been converted to letters or the empty word (nullableset<lal_char>).