HFST - Helsinki Finite-State Transducer Technology API
version 3.7.1
|
A stream for reading HFST binary transducers. More...
#include <HfstInputStream.h>
Public Member Functions | |
void | close (void) |
Close the stream. More... | |
ImplementationType | get_type (void) const |
The type of the first transducer in the stream. More... | |
HfstInputStream (void) | |
Create a stream to standard input for reading binary transducers. More... | |
HfstInputStream (const std::string &filename) | |
Open a stream to file filename for reading binary transducers. More... | |
bool | is_bad (void) |
Whether badbit is set. More... | |
bool | is_eof (void) |
Whether the stream is at end. More... | |
bool | is_good (void) |
Whether the state of the stream is good for input operations. More... | |
~HfstInputStream (void) | |
Destructor. More... | |
A stream for reading HFST binary transducers.
An example:
#include "HfstInputStream.h" ... HfstInputStream *in = NULL; try { in = new HfstInputStream("testfile"); } catch (StreamNotReadableException e) { std::cerr << "ERROR: File does not exist." << std::endl; exit(1); } int transducers_read = 0; while (not in->is_eof()) { if (in->is_bad()) { std::cerr << "ERROR: Stream cannot be read." << std::endl; exit(1); } HfstTransducer t(*in); std::cerr << "One transducer succesfully read." << std::endl; transducers_read++; } std::cerr << "Read " << transducers_read << " transducers in total." << std::endl; in->close(); delete in;
For documentation on the HFST binary transducer format, see here.
@see HfstTransducer::HfstTransducer(HfstInputStream &in)
HfstInputStream | ( | void | ) |
Create a stream to standard input for reading binary transducers.
HfstInputStream | ( | const std::string & | filename | ) |
Open a stream to file filename for reading binary transducers.
@throws StreamNotReadableException @throws NotTransducerStreamException @throws EndOfStreamException @throws TransducerHeaderException
~HfstInputStream | ( | void | ) |
Destructor.
void close | ( | void | ) |
Close the stream.
If the stream points to standard input, nothing is done.
ImplementationType get_type | ( | void | ) | const |
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.
bool is_bad | ( | void | ) |
Whether badbit is set.
bool is_eof | ( | void | ) |
Whether the stream is at end.
bool is_good | ( | void | ) |
Whether the state of the stream is good for input operations.