-
Notifications
You must be signed in to change notification settings - Fork 1
PackageHfstExceptions
-
HfstException
- HfstTransducerTypeMismatchException
- ImplementationTypeNotAvailableException
- FunctionNotImplementedException
- FlagDiacriticsAreNotIdentitiesException
- NotValidPrologFormatException
- StreamNotReadableException
- StreamCannotBeWrittenException
- StreamIsClosedException
- EndOfStreamException
- TransducerIsCyclicException
- NotTransducerStreamException
- NotValidAttFormatException
- NotValidLexcFormatException
- StateIsNotFinalException
- ContextTransducersAreNotAutomataException
- TransducersAreNotAutomataException
- StateIndexOutOfBoundsException
- TransducerHeaderException
- MissingOpenFstInputSymbolTableException
- TransducerTypeMismatchException
- EmptySetOfContextsException
- SpecifiedTypeRequiredException
- HfstFatalException
- TransducerHasWrongTypeException
- IncorrectUtf8CodingException
- EmptyStringException
- SymbolNotFoundException
- MetadataException
Base class for HfstExceptions. Holds its own name and the file and line number where it was thrown.
-
what()
: A message describing the error in more detail.
Two or more HfstTransducers are not of the same type.
Thrown by:
- E.g. HfstTransducer.concatenate(self, another) and other binary operator functions
The library required by the implementation type requested is not linked to HFST.
Thrown by all functions that require an ImplementationType parameter, if the implementation is not available (for the function in question).
Function has not been implemented (yet).
Flag diacritics encountered on one but not the other side of a transition.
Thrown by:
The input is not in valid prolog format.
Thrown by:
Stream cannot be read.
Thrown by: ...
Stream cannot be written.
Thrown by
Stream is closed.
Thrown by
An example:
try:
tr = hfst.regex('foo')
outstr = hfst.HfstOutputStream(filename='testfile')
outstr.close()
outstr.write(tr)
except hfst.exceptions.StreamIsClosedException:
print("Could not write transducer: stream to file was closed.")
The stream is at end.
Thrown by:
Transducer is cyclic.
Thrown by
An example
transducer = hfst.regex('[a:b]*')
try:
results = transducer.extract_paths(output='text')
print("The transducer has %i paths:" % len(results))
print(results)
except hfst.exceptions.TransducerIsCyclicException:
print("The transducer is cyclic and has an infinite number of paths. Some of them:")
results = transducer.extract_paths(output='text', max_cycles=5)
print(results)
The stream does not contain transducers.
Thrown by:
-
HfstInputStream.__init__(self, filename=None)
An example.
f = open('foofile', 'w')
f.write('This is an ordinary text file.\n')
f.close()
try:
instr = hfst.HfstInputStream('foofile')
tr = instr.read()
print(tr)
instr.close()
except hfst.exceptions.NotTransducerStreamException:
print("Could not print transducer: the file does not contain binary transducers.")
The stream is not in valid AT&T format.
An example:
f = open('testfile1.att', 'w')
f.write('0 1 a b\n\
1 2 c\n\
2\n')
f.close()
f = hfst.hfst_open('testfile1.att', 'r')
try:
tr = hfst.read_att(f)
except hfst.exceptions.NotValidAttFormatException:
print('Could not read file: it is not in valid ATT format.')
f.close()
The input is not in valid LexC format.
Thrown by: ...
State is not final (and cannot have a final weight).
An example :
tr = hfst.HfstBasicTransducer()
tr.add_state(1)
An exception is thrown as state number 1 is not final
try:
w = tr.get_final_weight(1)
except hfst.exceptions.StateIsNotFinalException:
print("State is not final.")
You should use function hfst.HfstBasicTransducer.is_final_state if you are not sure whether a state is final.
Thrown by:
Transducers given as rule context are not automata. See also: HfstTransducer.is_automaton(self)
Thrown by:
- two_level_if_and_only_if(context, mappings, alphabet)
Transducers are not automata.
Example:
tr1 = hfst.regex('foo:bar')
tr2 = hfst.regex('bar:baz')
try:
tr1.cross_product(tr2)
except hfst.exceptions.TransducersAreNotAutomataException:
print('Transducers must be automata in cross product.')
This exception is thrown by
[[HfstTransducer.cross_product(self, another)|HfstTransducer#cross_product-self-another]]
when either input transducer does not have equivalent input and
output symbols in all its transitions.
The state number argument is not valid.
An example :
tr = hfst.HfstBasicTransducer()
tr.add_state(1)
try:
w = tr.get_final_weight(2)
except hfst.exceptions.StateIndexOutOfBoundsException:
print('State number 2 does not exist')
See also: HfstBasicTransducer.is_final_state(self, state)
Thrown by:
Todo: Return None instead of throwing an error?
Transducer has a malformed HFST header.
Thrown by:
An OpenFst transducer does not have an input symbol table.
When converting from OpenFst to tropical or log HFST, the OpenFst transducer
must have at least an input symbol table. If the output symbol table
is missing, it is assumed to be equivalent to the input symbol table.
Two or more transducers do not have the same type.
This can happen if (1) the calling and called transducer in a binary
operation, (2) two transducers in a pair of transducers,
(3) two consecutive transducers coming from an HfstInputStream or
(4) two transducers in a function taking two or more transducers as
arguments do not have the same type.
An example:
hfst.set_default_fst_type(hfst.types.TROPICAL_OPENFST_TYPE)
tr1 = hfst.regex('foo')
tr2 = hfst.regex('bar')
tr2.convert(hfst.types.FOMA_TYPE)
try:
tr1.disjunct(tr2)
except hfst.exceptions.TransducerTypeMismatchException:
print('The implementation types of transducers must be the same.')
The set of transducer pairs is empty.
Thrown by rule functions.
The type of a transducer is not specified.
This exception is thrown when an implementation type argument is hfst.types.ERROR_TYPE.
An error happened probably due to a bug in the HFST code.
Transducer has wrong type.
This exception suggests that an HfstTransducer has not been properly
initialized, probably due to a bug in the HFST library. Alternatively
the default constructor of HfstTransducer has been called at some point.
See also: hfst.HfstTransducer.\_\_init\_\_
String is not valid utf-8.
This exception suggests that an input string is not valid utf8.
An argument string is an empty string. A transition symbol cannot be an empty string.
A bug in the HFST code.
A piece of metadata in an HFST header is not supported.
Package hfst
- AttReader
- PrologReader
- HfstBasicTransducer
- HfstBasicTransition
- HfstTransducer
- HfstInputStream
- HfstOutputStream
- MultiCharSymbolTrie
- HfstTokenizer
- LexcCompiler
- XreCompiler
- PmatchContainer
- ImplementationType