Test a twol rule file using correspondences of strings.


The help message

Usage: hfst-pair-test [OPTIONS...] [INFILE]
pair test for a twolc rule file.

Common options:
  -h, --help             Print help message
  -V, --version          Print version info
  -v, --verbose          Print verbosely while processing
  -q, --quiet            Only print fatal erros and requested output
  -s, --silent           Alias of --quiet
Input/Output options:
  -i, --input=INFILE     Read input rule file from INFILE
  -o, --output=OUTFILE   Write test output to OUTFILE
  -N  --negative-test    Test fails if any of the pair strings is
  -X  --xerox-mode       In xerox mode, test cases are harvested
                         from a twolc source file.
Pair test options:
  -I, --input-strings=SFILE        Read pair test strings from

If SFILE is missing, the test pair strings are read from STDIN.
If OUTFILE is missing, test output is written to STDOUT.

The rule file is tested using correspondences given as
pair strings, e.g. "e a r l y:i e r". Every pair string is
tested using every rule and the program prints information
about correspondences that are incorrectly allowed or

The test pair string files contain one pair string/line. Lines
where the first non-white-space character is "!" are
considered comment lines and skipped.

There are three test modes positive, negative and Xerox mode. In
positive mode, all of the pair strings should be allowed and in
negative mode they should be disallowed. In Xerox mode the cases
are read from a twolc source file and both positive and negative
cases can occur.

Ordinarily, positive test mode is in use. Option -N switches to
negative test mode. The exit code for a successful test is 0.
The exit code is 1 otherwise. A successful test will print
"Test passed". A failing test prints "Test failed" and
information about pair strings that are handled incorrectly.

In positive test mode (i.e. without option -N), if a pair
string is not accepted, the names of the rules that reject
it are printed as well as the positions in the string where the
rules run out of possible transitions. In negative mode, only
the strings that are allowed are printed.

In Xerox mode, the input should be a twolc file. Tests consist of
two lines: an input form and an output form. The test cases are
specialized comments prefixed with either '!' or '!$' depeding on
whether the pair should succeed or fail. An example of a positive

! earlYer
! earlier

An example of a negative test:

!$ earlYer
!$ earlyer

In silent mode (-s), the program won't print anything. Only the
exit code tells whether the test was successful or not.

Report bugs to <hfst-bugs@helsinki.fi> or directly to our bug tracker at:


Take the rule file i-rules.twolc

! i-rules.twolc


a e i o u y   
<I>:i <I>:j ;


vowel = a e i o u y    ;


"<I> rule"
<I>:j <=> :vowel _ :vowel;

Now <I> should be realized as j between vowels and as i everywhere else. In order to test the rules, we can write a positive test file i-rules.test

! i-rules.test

! test file for i-rules.twolc
! positive test cases.
! <I> is realized as j between
! vowels and i otherwise.

t a k k e <I>:j a
t a k e <I>:i s s a

and negative test file i-rules.neg.test.

! i-rules.neg.test

! test file for i_rules.twolc
! negative test cases.
! <I> is realized as j between
! vowels and i otherwise.

t a k k e <I>:i a
t a k e <I>:j s s a

The tests are run using the commands

hfst-pair-test -i i-rules.twolc.hfst -I i-rules.test
hfst-pair-test -N -i i-rules.twolc.hfst -I i-rules.neg.test