Humanizr/Humanizer · error · InvalidOperationException
Productive evidence '{direction}' requires at least 100 atte
Error message
Productive evidence '{direction}' requires at least 100 attempts and 99% correctness. What it means
During source generation, the inflection catalog validator checks that every direction (pluralize/singularize) with productive rules reports statistically significant evidence. The 'attempted' count must be >= 100 and the correctness ratio (correct/attempted) must be >= 99%. This is a build-time guard ensuring productive inflection rules are backed by sufficient empirical test data before shipping.
Source
Thrown at src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogValidation.cs:89
}
if (irregular == 0 && eligible == 0)
{
throw new InvalidOperationException(
$"Inflection evidence '{direction}' N/A coverage requires a positive eligible census.");
}
if (!hasProductiveRules)
{
return;
}
var attempted = GetRequiredInt(values, "attempted", $"Productive evidence '{direction}' must define attempted");
var correct = GetRequiredInt(values, "correct", $"Productive evidence '{direction}' must define correct");
if (attempted < 100 || correct < 0 || correct > attempted ||
correct * 100L < attempted * 99L)
{
throw new InvalidOperationException(
$"Productive evidence '{direction}' requires at least 100 attempts and 99% correctness.");
}
}
static void ValidateSources(
SimpleYamlMapping mapping,
ImmutableHashSet<string> sourceIds,
string subject)
{
foreach (var source in GetRequiredStrings(mapping, "sources", $"{subject} must define sources"))
{
if (!sourceIds.Contains(source))
{
throw new InvalidOperationException($"{subject} references unknown source '{source}'.");
}
}
}
View on GitHub (pinned to ffc2b77c0f)
Solutions
- Increase the 'attempted' value in the locale's evidence block to at least 100 and ensure 'correct' is at least 99% of 'attempted'.
- If the rule set is not yet empirically validated, remove the productive rules from the bundle so hasProductiveRules becomes false and this check is skipped.
- Verify the YAML evidence numbers reflect real test corpus runs — re-run the inflection evidence harness and copy actual figures.
Example fix
# before (in <locale>.yml inflection evidence)
evidence:
pluralize:
attempted: 50
correct: 49
# after
evidence:
pluralize:
attempted: 200
correct: 198 Defensive patterns
Strategy: validation
Validate before calling
# Before building, verify evidence numbers in locale YAML meet the threshold.
# Run a YAML lint check or pre-build script:
python3 -c "
import yaml, sys
for f in sys.argv[1:]:
d = yaml.safe_load(open(f))
ev = d.get('inflection',{}).get('evidence',{})
for direction in ('pluralize','singularize'):
blk = ev.get(direction,{})
attempted = blk.get('attempted',0)
correct = blk.get('correct',0)
if attempted > 0 and (attempted < 100 or correct * 100 < attempted * 99):
print(f'{f}: {direction} evidence below threshold (attempted={attempted}, correct={correct})')
" src/Humanizer/Locales/*.yml Prevention
- Run the inflection evidence test harness before editing locale YAML to capture real attempted/correct figures.
- Add a CI YAML schema check that enforces attempted >= 100 and correct/attempted >= 0.99 for any direction with productive rules.
- When adding productive rules to a locale, immediately update the evidence block with fresh corpus numbers.
When it happens
Trigger: An inflection owner's YAML evidence block for 'pluralize' or 'singularize' has 'attempted' < 100, or 'correct' * 100 < 'attempted' * 99. Only fires when hasProductiveRules is true (i.e., the bundle defines at least one forward/reverse rule).
Common situations: Adding a new locale with productive inflection rules but underestimating the evidence corpus. Raising the attempted count for testing without also raising correct. Typo in the YAML making 'attempted' or 'correct' parse as a small number.
Related errors
- {subject} references unknown source '{source}'.
- Inflection source '{entry.Key}' must define non-empty kind a
- Inflection source '{entry.Key}' {optionalProperty} must be a
- Inflection rule '{ruleId}' output must contain exactly one b
- Invariant bundle cannot define productive rules.
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/74a853e939d30881.
Report an issue: GitHub.