Test Foma FSTs
Project description
fsttest
Test your Foma FSTs!
Install
For macOS users with Homebrew:
$ brew install eddieantonio/eddieantonio/fsttest
For everybody else:
$ pip install fsttest
Usage
Write test_*.toml
scripts in a folder called tests/
, then run:
$ fsttest
Documentation
Tutorial
In your FST project, create a folder called tests/
:
$ mkdir tests
Within this folder create a file called test_{something}.toml
where
{something}
is something specific to your FST. For example,
test_phonology.toml
:
$ touch tests/test_phonology.toml
Use the following template to create your test:
# tests/test_phonology.toml
[fst]
eval = "rewrite_rules.xfscript"
compose = ["TInsertion", "NiTDeletion", "Cleanup"]
[[tests]]
upper = "ni<ayaa<n"
expect = "dayaan"
[[tests]]
lower = "ki<tayaa<n"
expect = "kiayaan"
Then run the test!
$ fsttest
1/1 tests passed! ✨ 🍰 ✨
Line-by-line
Let's breakdown this file, line-by-line.
[fst]
This defines the FST under test — that is, the FST we want to use to transduce and test its output.
eval = "rewrite_rules.xfscript"
This says that our FST under test can be created by running
rewrite_rules.xfscript
in Foma, creating an FST. As an example, let's
take the following rewrite_rules.xfscript
:
# rewrite_rules.xfscript
define Vowel a | e | i | o | u ;
define TInsertion [..] -> t || [n i | k i] "<" _ Vowel ;
define NiTDeletion n i "<" t -> d || _ Vowel ;
define Cleanup %< -> 0 ;
Yours will be different!
compose = ["TInsertion", "NiTDeletion"]
This line says that the FST under test is the result of composing
the TInsertion
regex with the NiTDeletion
regex. That is, the FST
puts its input into TInsertion
and then passes the result to
NiTDeletion
. The result of passing it through both FSTs is the result
we want to test.
[[tests]]
Next we define one or more test cases. Begin every test case with
[[tests]]
: note the two square brackets!
upper = "ni<ayaa<n"
This test case feeds the string ni<ayaa<n
into the upper side of the
FST. The upper side is conventionally the analysis side of the FST.
expect = "dayaan"
This says that we expect the lower side to be dayaa<n
. That is,
this test case says that, given the analysis ni<ayaa<n
, the FST should
produce dayaa<n
among the possible surface forms.
[[tests]]
Next, we define another test case.
lower = "kitayaan"
In contrast to the previous test, we feed the input to the lower side of the FST. In other words, we want to do a lookup. Conventionally, this means we're providing a surface form, and asking the FST to return an analysis.
expect = "ki<ayaa<n"
This means we're expecting the analysis of ki<tayaa<n
when we give
the FST the wordform of kitayaan
License
Written in 2020 by Eddie Antonio Santos Eddie.Santos@nrc-cnrc.gc.ca.
Licensed under the terms of the Mozilla Public License 2.0 (MPL-2.0).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fsttest-0.5.0.tar.gz
.
File metadata
- Download URL: fsttest-0.5.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.2 CPython/3.6.7 Linux/4.15.0-1028-gcp
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34c8a3e4b95c7a6b177852740c11d3c996140371a4595195112b2d3caa2fbeb6 |
|
MD5 | 15c4e6dd8df6d073d82b668e9610b3f2 |
|
BLAKE2b-256 | 53c3c9013f365e9c97a4c09312c0c484e9ceea0f25f3c37dd7a591e36e920758 |
File details
Details for the file fsttest-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: fsttest-0.5.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.2 CPython/3.6.7 Linux/4.15.0-1028-gcp
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c300438f4f48f510d8e79f4e52cb5994f982c7aa1269ed5108b298b5c5729316 |
|
MD5 | a098ebfe1802bc2510ed3a1c081ad44f |
|
BLAKE2b-256 | 1af70523c272fff574403ef3c2600eee25b0298ca34bf47c5df84757c3a2d02b |