Repository navigation
remove punctuation caveat - #130
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It reworks the core counting/accounting logic that all solver variants depend on, involving intricate separator and punctuation-name math that warrants human verification despite only one minor issue being found.
1 open issue
What changed in this PR
This PR removes the long-standing "punctuation caveat" from autogram configuration. Previously, pluralised punctuation names (e.g. "commas") were pre-baked into the template baseline and separator characters had their baseline deducted by 2 (which could go negative and break byte solvers). The refactor makes BaselineCount always nonnegative (template + conjunction only), accounts for omitted trailing separators by flagging specific guaranteed entries with a new OmitSeparator property, and introduces GuaranteedNameContribution so repeated letters in punctuation names (e.g. the two "m"s in "comma") are counted correctly. This touches the core AutogramConfig/AutogramConfigFactory, which every solver variant consumes.
Changes:
- Replaced
UnadjustedBaselineCount+SeparatorCountModifierwith a nonnegativeBaselineCount, and addedGuaranteedNameContributionandOmitSeparator/EntrySeparatorto model separator omission and punctuation-name minimums. - Reworked
MakeAutogramConfigto compute per-character letter tables, assign the separator correction to the first N guaranteed entries (throwing when there aren't enough), and fold exact singular/plural name contributions into minimum counts. - Updated and added tests, including a new
SeparatorAccountingTestssuite that cross-checks lookup totals against rendered sentences.
| File | Description |
|---|---|
| Autogram/AutogramConfig.cs | Introduces nonnegative BaselineCount, GuaranteedNameContribution, OmitSeparator/EntrySeparator; updates string-representation generation. |
| Autogram/AutogramConfigFactory.cs | Core refactor of baseline/minimum computation, separator-omission accounting, and exact name contributions. |
| AutogramTest/SeparatorAccountingTests.cs | New suite verifying lookup totals match rendered output and separator/guaranteed-entry invariants. |
| AutogramTest/AutogramConfigFactoryTest.cs | Adds punctuation-name tests and migrates assertions to BaselineCount (contains a duplicate assertion). |
| AutogramTest/AutogramConfigTest.cs | Updates MakeCharacter helper to set BaselineCount. |
| AutogramTest/AutogramTest.cs | Updates "alphabet too large" tests to set BaselineCount. |
Review effort: Balanced
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

This pull request makes several important changes to how autogram character counts are calculated and tracked, especially for punctuation and separator characters. It refactors the handling of baseline and minimum counts, improves the accuracy of contributions from character names (like "comma"/"commas"), and updates tests to reflect these changes.
Core logic improvements:
CharacterConfigto replaceUnadjustedBaselineCountwithBaselineCount, clarifying that the baseline is now always nonnegative and directly reflects the template and conjunction, before list entries are generated. (Autogram/AutogramConfig.cs, Autogram/AutogramConfig.csL56-R71)MinimumCountto include a newGuaranteedNameContributionfield, ensuring that repeated letters in punctuation names (e.g., the two 'm's in "comma") are accurately counted. (Autogram/AutogramConfig.cs, [1];Autogram/AutogramConfigFactory.cs, [2]OmitSeparatorproperty and logic to ensure omitted separators at the end of lists are correctly accounted for in guaranteed entries, preventing negative baseline counts. (Autogram/AutogramConfig.cs, [1];Autogram/AutogramConfigFactory.cs, [2]Test updates:
AutogramTest/AutogramConfigFactoryTest.cs, [1] [2] [3]BaselineCountproperty instead ofUnadjustedBaselineCount. (AutogramTest/AutogramConfigTest.cs, [1];AutogramTest/AutogramTest.cs, [2] [3]Supporting code and performance:
Autogram/AutogramConfig.cs, [1];Autogram/AutogramConfigFactory.cs, [2]These changes collectively ensure that autogram configuration is more robust, especially in edge cases involving punctuation and separators, and that tests accurately reflect the new counting logic.