param_cnt: reject invalid inputs instead of crashing or reporting false success - #66
Merged
Conversation
…se success Turn several param_cnt failure modes into named initialization errors: - Require -segdir only for state and cb counting; phone counting does not need segmentations, so a missing -segdir is required where it is actually used and no longer forced everywhere. - Check corpus_set_ctl_filename() and fail on an unusable control file. - Require -ts2cbfn for cb counting so cb_cnt never indexes a null state-to-codebook map. - Reject an unknown -paramtype instead of scanning with an unset counting function pointer. - Have enum_corpus() report the number of utterances that reached the counting callback (skipping an indented first-line comment), and reject a zero count before any output is written. - Open -outputfn only after enumeration produced nonzero work, so a failed run never leaves an empty or all-zero count file behind. Fixes #65.
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.
Fixes #65.
param_cntturned several invalid-input conditions into either a crash or asuccessful exit. This makes each one an ordinary, named initialization failure,
and defers creating the output file until a nonzero count exists.
What changes
-segdiris required only where it is used. State and codebook countingneed segmentations; phone counting does not. A missing
-segdiris now anamed error for
state/cband is accepted forphone, instead of passing anull value into
corpus_set_seg_dir().corpus_set_ctl_filename()'s result is nolonger discarded; an unusable
-ctlfnfails initialization.cbcounting requires-ts2cbfn. Without it,mdef->cbis neverpopulated and
cb_cnt()would index a null map. Counting now refuses to start.-paramtypeis rejected instead of scanning the corpus with anunset counting-function pointer.
enum_corpus()now returns thenumber of utterances that reached the counting callback (and skips an indented
first-line comment that
lineiter_start_clean()can otherwise expose as acontrol entry). A control that yields no counted utterance — empty,
whitespace-only, or comment-only — fails instead of producing an all-zero file.
-outputfnis opened only after enumeration produced nonzero work, so afailed run never leaves an empty or all-zero count file behind. A failed
fopen()is now a nonzero exit rather than a silent write to a null stream.Verification
param_cntbuilds cleanly (no new warnings).param_cnt -paramtype statewithout
-segdirnow printsYou must specify a segmentation directory using -segdirand exits 1;-paramtype phoneno longer requires-segdir. Thecounting core matches the implementation carried and tested downstream, whose
boundary suite covers empty / whitespace-only / indented-comment-only controls,
a directory / unreadable file /
/dev/nullcontrol, a malformed later controlline, unknown type, missing codebook mapping, output-open failure, and
successful phone counting without
-segdir.Out of scope: the
cmd_ln_parse()return-contract issue (#63) and the separatepre-existing
-sentdirdereference reachable when-lsnfnis absent.