- Notifications
You must be signed in to change notification settings - Fork1
PrologReader
A class for reading input in prolog text format and converting it into transducer(s).
The easiest way to create transducers from prolog files are probably the functionshfst.read_prolog_transducer(f, linecount) andhfst.read_prolog_transducer(f).
An example that reads prolog input from file 'testfile.prolog'and creates the corresponding transducers and prints them. If the input cannot be parsed, a message showing theinvalid line in prolog input is printed and reading is stopped.
with open('testfile.prolog', 'r') as f: try: r = hfst.PrologReader(f) for tr in r: print(tr) except hfst.exceptions.NotValidPrologFormatException as e: print(e.what())Create a PrologReader that reads input from filef.
fA python file.
Read next transducer.
Read next transducer description in prolog format and return a corresponding transducer.
An iterator to the reader.
Needed for 'for ... in' statement.
for transducer in prolog_reader: print(transducer)Return next element (for python version 2).
Needed for 'for ... in' statement.
for transducer in prolog_reader: print(transducer)- StopIteration
Return next element (for python version 3).
Needed for 'for ... in' statement.
for transducer in prolog_reader: print(transducer)- StopIteration