HFST - Helsinki Finite-State Transducer Technology - Python API
version 3.12.1
|
A stream for reading HFST binary transducers. More...
Public Member Functions | |
def | __init__ |
Create a stream for reading binary transducers. More... | |
def | close |
Close the stream. More... | |
def | get_type |
The type of the first transducer in the stream. More... | |
def | is_bad |
Whether badbit is set. More... | |
def | is_eof |
Whether the stream is at end. More... | |
def | is_good |
Whether the state of the stream is good for input operations. More... | |
def | read |
Return next transducer. More... | |
A stream for reading HFST binary transducers.
An example:
istr = hfst.HfstInputStream('testfile1.hfst') transducers = [] while not (istr.is_eof()): transducers.append(istr.read()) istr.close() print("Read %i transducers in total." % len(transducers))
For documentation on the HFST binary transducer format, see here.
def __init__ | ( | self, | |
filename = None |
|||
) |
Create a stream for reading binary transducers.
filename | The name of the transducer file. If not given, standard input is used. |
StreamNotReadableException | |
NotTransducerStreamException | |
EndOfStreamException | |
TransducerHeaderException | istr_to_stdin = hfst.HfstInputStream() istr_to_file = hfst.HfstInputStream(filename='transducer.hfst') |
def close | ( | self | ) |
Close the stream.
If the stream points to standard input, nothing is done.
def get_type | ( | self | ) |
The type of the first transducer in the stream.
By default, all transducers in a stream have the same type, else a TransducerTypeMismatchException is thrown when reading the first transducer that has a different type than the previous ones.
def is_bad | ( | self | ) |
Whether badbit is set.
def is_eof | ( | self | ) |
Whether the stream is at end.
def is_good | ( | self | ) |
Whether the state of the stream is good for input operations.
def read | ( | self | ) |
Return next transducer.
EndOfStreamException |