Skip to content

remove punctuation caveat - #130

Merged
jamesmoore merged 6 commits into
mainfrom
remove-punctuation-caveat
Oct 20, 2026
Merged

jamesmoore merged 6 commits into
mainfrom
remove-punctuation-caveat

Conversation

@jamesmoore

Copy link
Copy Markdown
Owner

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:

  • Refactored CharacterConfig to replace UnadjustedBaselineCount with BaselineCount, 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)
  • Modified the calculation of MinimumCount to include a new GuaranteedNameContribution field, 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]
  • Improved separator handling by introducing the OmitSeparator property 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:

  • Updated and added unit tests to verify the new logic for punctuation name contributions and separator handling, including cases for repeated characters and minimum counts for punctuation. (AutogramTest/AutogramConfigFactoryTest.cs, [1] [2] [3]
  • Adjusted test expectations and test setup to use the new BaselineCount property instead of UnadjustedBaselineCount. (AutogramTest/AutogramConfigTest.cs, [1]; AutogramTest/AutogramTest.cs, [2] [3]

Supporting code and performance:

  • Optimized string representation generation by using precomputed cardinal number strings and improved how per-character letter contributions are calculated for variable characters. (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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 + SeparatorCountModifier with a nonnegative BaselineCount, and added GuaranteedNameContribution and OmitSeparator/EntrySeparator to model separator omission and punctuation-name minimums.
  • Reworked MakeAutogramConfig to 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 SeparatorAccountingTests suite 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

Comment thread AutogramTest/AutogramConfigFactoryTest.cs Outdated
@jamesmoore
jamesmoore merged commit a5bfa00 into main Oct 20, 2026
4 checks passed
@jamesmoore
jamesmoore deleted the remove-punctuation-caveat branch October 20, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants