HFST - Helsinki Finite-State Transducer Technology - Python API  version 3.9.0
Public Member Functions | List of all members
HfstOutputStream Class Reference

A stream for writing binary transducers. More...

Public Member Functions

def __init__
 Open a stream for writing binary transducers. More...
 
def close
 Close the stream. More...
 
def flush
 Flush the stream. More...
 
def write
 Write the transducer transducer in binary format to the stream. More...
 

Detailed Description

A stream for writing binary transducers.

An example:

 res = ['foo:bar','0','0 - 0','"?":?','a* b+']
 ostr = libhfst.HfstOutputStream(filename='testfile1.hfst')
 for re in res:
     ostr.write(libhfst.regex(re))
     ostr.flush()
 ostr.close()

For more information on HFST transducer structure, see this page.

Constructor & Destructor Documentation

def __init__ (   self,
  kvargs 
)

Open a stream for writing binary transducers.

Parameters
kvargsArguments recognized are filename, hfst_format, type.
filenameThe name of the file where transducers are written. If the file exists, it is overwritten. If filename is not given, transducers are written to standard output.
hfst_formatWhether transducers are written in hfst format (default is True) or as such in their backend format.
typeThe type of the transducers that will be written to the stream. Default is libhfst.get_default_fst_type().

Member Function Documentation

def close ( )

Close the stream.

If the stream points to standard output, nothing is done.

def flush ( )

Flush the stream.

def write (   transducer)

Write the transducer transducer in binary format to the stream.

All transducers must have the same type as the stream, else a TransducerTypeMismatchException is thrown.

Exceptions
TransducerTypeMismatchException

The documentation for this class was generated from the following file: