apertium / lttoolbox

Finite state compiler, processor and helper tools used by apertium
http://wiki.apertium.org/wiki/Lttoolbox
GNU General Public License v2.0
18 stars 22 forks source link

add HFST compatibility option to lt-print #79

Closed mr-martian closed 4 years ago

mr-martian commented 4 years ago

This PR adds a -H/--hfst option to lt-print to print transducers with character escapes that can be read by hfst-txt2fst. It also adds this option to transducer.show().

(In case anyone wonders, the argument order on show() is because if the hfst parameter is last and you try to pass in a bool, it gets casted to an int and interpreted as epsilon_tag.)

TinoDidriksen commented 4 years ago

Is Transducer::show() used in any downstream project? If so, this would be a major version bump.

Adding the new param to the end should be preferred, and the only cost is passing explicit 0 in your new code.

TinoDidriksen commented 4 years ago

show() is used: https://github.com/apertium/apertium-lex-tools/blob/master/src/lrx_compiler.cc#L978 and https://github.com/apertium/apertium-lex-tools/blob/master/src/lrx_compiler.cc#L986

We can avoid a major version bump by adding an overload. Keep the old show(Alphabet, FILE*, int), but forward it to the extended version with bool=false.

mr-martian commented 4 years ago

I've moved the new parameter to the end.

Also, the epsilon_tag parameter is completely ignored.

TinoDidriksen commented 4 years ago

Merged, with a minor addition to keep binary compat.