Skip to main content

fsttest

Test your Foma FSTs!

Install

$ 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).

Metadata

Release files for fsttest 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fsttest 0.2.1
File Size Uploaded Provenance Actions
fsttest-0.2.1.tar.gz 12.7 kB Without provenance Details for fsttest-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fsttest 0.2.1
File Interpreter ABI Platform Actions
fsttest-0.2.1-py3-none-any.whl Python 3 none any Details for fsttest-0.2.1-py3-none-any.whl

Total release size: 26.4 kB

Release files / fsttest-0.2.1.tar.gz

Download URL fsttest-0.2.1.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
951fad1e72bff8c3a37816c52b4e8e8d5021c9c6a64046c0ff176b2ae2b28f8e
BLAKE2b-256 checksum
How to use checksums
81add5650e76ed57fae775852a548f2ecf2ca388a6c2538e3e0e95717bc6d4c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.2 CPython/3.7.6 Darwin/19.0.0

Release files / fsttest-0.2.1-py3-none-any.whl

Download URL fsttest-0.2.1-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59662d658580529f3a7efcdb6bb8d87e762fe3ba1dfef9eb23c6e07aabd707d9
BLAKE2b-256 checksum
How to use checksums
f0cb107f7dd5cc2f007711104126ffe6460f63f6376f6dc19de1ea1bf68cb9d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.2 CPython/3.7.6 Darwin/19.0.0

Security for fsttest 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page