HFST - Helsinki Finite-State Transducer Technology - Python API
version 3.12.1
|
A class for reading input in AT&T text format and converting it into transducer(s). More...
Public Member Functions | |
def | __init__ |
Create an AttReader that reads input from file f where the epsilon is represented as epsilonstr. More... | |
def | __iter__ |
An iterator to the reader. More... | |
def | __next__ |
Return next element (for python version 3). More... | |
def | next |
Return next element (for python version 2). More... | |
def | read |
Read next transducer. More... | |
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 "<eps>" 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())
def __init__ | ( | self, | |
f, | |||
epsilonstr = EPSILON |
|||
) |
Create an AttReader that reads input from file f where the epsilon is represented as epsilonstr.
f | A python file. |
epsilonstr | How epsilon is represented in the file. By default, "@_EPSILON_SYMBOL_@" and "@0@" are both recognized. |
def __iter__ | ( | self | ) |
An iterator to the reader.
Needed for 'for ... in' statement.
for transducer in att_reader: print(transducer)
def __next__ | ( | self | ) |
Return next element (for python version 3).
Needed for 'for ... in' statement.
for transducer in att_reader: print(transducer)
StopIteration |
def next | ( | self | ) |
Return next element (for python version 2).
Needed for 'for ... in' statement.
for transducer in att_reader: print(transducer)
StopIteration |
def read | ( | self | ) |
Read next transducer.
Read next transducer description in AT&T format and return a corresponding transducer.