Document and test the forced-alignment variant-token contract - #504
Open
lenzo-ka wants to merge 1 commit into
Open
Document and test the forced-alignment variant-token contract#504lenzo-ka wants to merge 1 commit into
lenzo-ka wants to merge 1 commit into
Conversation
ps_set_align_text() looks up each token with an exact dictionary lookup, so an explicit pronunciation variant such as "a(2)" is aligned with only that entry's phones, a base spelling such as "a" remains free to use any of its alternate pronunciations, and an unknown spelling such as "a(99)" is rejected. Document this on ps_set_align_text() and add tests for it. test_align_text_variant checks that an unknown variant returns -1 while a transcript of known base and variant spellings is accepted. test_align_variant_alt inspects the constructed alignment FSG: a base token contributes an alternate-pronunciation transition, while an explicit variant token does not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ps_set_align_text()verifies each token with an exact dictionary lookup and builds the alignment FSG from the spelling supplied. This gives forced alignment a useful variant-token contract that was neither documented nor tested:a(2)is aligned with only that dictionary entry's pronunciation (in the shippedcmudict-en-us.dict,aisAHanda(2)isEY).aremains free to use any of its alternate pronunciations.a(99)is rejected, andps_set_align_text()returns -1.This documents the contract on
ps_set_align_text()and adds tests for it, with no behavior change.test_align_text_variantchecks that an unknown variant returns -1 while a transcript of known base and variant spellings is accepted.test_align_variant_altinspects the constructed_alignFSG: a base token contributes an alternate-pronunciation transition, while an explicit variant token does not.Fixes #503
Tested on macOS (Apple clang) and Linux x86-64 (GCC 13.3); full unit and regression suite passes on both.