Skip to main content

Test Foma FSTs

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fsttest-0.2.1.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

fsttest-0.2.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file fsttest-0.2.1.tar.gz.

File metadata

  • Download URL: fsttest-0.2.1.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.2 CPython/3.7.6 Darwin/19.0.0

File hashes

Hashes for fsttest-0.2.1.tar.gz
Algorithm Hash digest
SHA256 951fad1e72bff8c3a37816c52b4e8e8d5021c9c6a64046c0ff176b2ae2b28f8e
MD5 be730bbbb587bc3dda843fbd9011c704
BLAKE2b-256 81add5650e76ed57fae775852a548f2ecf2ca388a6c2538e3e0e95717bc6d4c7

See more details on using hashes here.

File details

Details for the file fsttest-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: fsttest-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.2 CPython/3.7.6 Darwin/19.0.0

File hashes

Hashes for fsttest-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 59662d658580529f3a7efcdb6bb8d87e762fe3ba1dfef9eb23c6e07aabd707d9
MD5 5d6cea384be59e72b611516212edef36
BLAKE2b-256 f0cb107f7dd5cc2f007711104126ffe6460f63f6376f6dc19de1ea1bf68cb9d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page