Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 45899
Kernel: Python 3

context.trie(data="", format="default", filename="")

Generate a "trie" automaton (a prefix tree) from a finite series, given as a file of (weighted) words.

Arguments:

  • data: a string containing the list of words

  • format:

    • "default": same as "monomials"

    • "monomials": each line contains a weighted word in the monomials syntax: <2>foo

    • "words": each line contains a single word: foo. In this case <2>foo is read as a five-letter word.

Postconditions:

  • Result.is_deterministic()

See also:

Examples

Words (finite language)

import vcsn vcsn.B.trie('''foo bar baz''')
Image in a Jupyter notebook
%%file words hello world hell word
Overwriting words
vcsn.B.trie(filename='words')
Image in a Jupyter notebook

Weighted words (finite series)

vcsn.Q.trie(''' one <2>two <3>three <13>thirteen <30>thirty <51>thirsty''')
Image in a Jupyter notebook

Tuples of words

vcsn.context('lat<law_char, law_char>, q').trie(''' <1>one|un <2>two|deux <3>three|trois <4>four|quatre <14>forteen|quatorze <40>forty|quarante''')
Image in a Jupyter notebook