-
Notifications
You must be signed in to change notification settings - Fork 1
AttReader
A class for reading input in AT&T text format and converting it into transducer(s).
An example that reads AT&T input from file 'testfile.att' where epsilon is represented as "" and creates the corresponding transducers and prints them. If the input cannot be parsed, a message showing the invalid line in AT&T input is printed and reading is stopped.
with open('testfile.att', 'r') as f:
try:
r = hfst.AttReader(f, "<eps>")
for tr in r:
print(tr)
except hfst.exceptions.NotValidAttFormatException as e:
print(e.what())
Create an AttReader that reads input from file \a f where the epsilon is represented as \a epsilonstr.
@param f A python file. @param epsilonstr How epsilon is represented in the file. By default, "@EPSILON_SYMBOL@" and "@0@" are both recognized.
Read next transducer. Read next transducer description in AT&T format and return a corresponding transducer. @throws hfst.exceptions.NotValidAttFormatException @throws hfst.exceptions.EndOfStreamException
An iterator to the reader. Needed for 'for ... in' statement.
for transducer in att_reader:
print(transducer)
Return next element (for python version 2). Needed for 'for ... in' statement.
for transducer in att_reader:
print(transducer)
Return next element (for python version 3). Needed for 'for ... in' statement.
for transducer in att_reader:
print(transducer)
Read next transducer from prolog file pointed by \a f. @param f A python file.
If the file contains several transducers, they must be separated by empty lines.
Package hfst
- AttReader
- PrologReader
- HfstBasicTransducer
- HfstBasicTransition
- HfstTransducer
- HfstInputStream
- HfstOutputStream
- MultiCharSymbolTrie
- HfstTokenizer
- LexcCompiler
- XreCompiler
- PmatchContainer
- ImplementationType