Humanizr/Humanizer · error · InvalidOperationException

Inflection lexeme '{id}' pos must be 'noun'.

Error message

Inflection lexeme '{id}' pos must be 'noun'.

What it means

The inflection engine currently only inflects nouns, so each lexeme's 'pos' must be the literal string 'noun'. ParseLexemes throws for any other value.

Source

Thrown at src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogParsing.cs:262

            {
                if (value is not SimpleYamlMapping lexeme)
                {
                    throw new InvalidOperationException("Inflection lexemes must be mappings.");
                }

                ValidateProperties(
                    lexeme,
                    "Inflection lexeme",
                    "id", "pos", "countability", "sense", "forms", "sources");
                var id = GetRequiredScalar(lexeme, "id", "Inflection lexeme must define id");
                if (!ids.Add(id))
                {
                    throw new InvalidOperationException($"Duplicate inflection lexeme id '{id}'.");
                }

                if (GetRequiredScalar(lexeme, "pos", $"Inflection lexeme '{id}' must define pos") != "noun")
                {
                    throw new InvalidOperationException($"Inflection lexeme '{id}' pos must be 'noun'.");
                }

                var countability = GetRequiredScalar(
                    lexeme,
                    "countability",
                    $"Inflection lexeme '{id}' must define countability");
                if (!Countabilities.Contains(countability))
                {
                    throw new InvalidOperationException(
                        $"Inflection lexeme '{id}' countability '{countability}' is unsupported.");
                }

                string? sense = null;
                if (lexeme.TryGetValue("sense", out var senseValue))
                {
                    if (senseValue is not SimpleYamlScalar senseScalar ||
                        string.IsNullOrWhiteSpace(senseScalar.Value))
                    {

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Set 'pos: 'noun'' exactly
  2. Omit the lexeme until its part of speech is supported

Example fix

# before
      - id: 'zz.verb.run'
        pos: 'verb'
# after
      - id: 'zz.noun.cat'
        pos: 'noun'
Defensive patterns

Strategy: validation

Validate before calling

foreach (var lexeme in lexemes)
    if (lexeme.Pos != "noun")
        Report($"{locale}: lexeme '{lexeme.Id}' pos must be 'noun'.");

Type guard

static bool AllPosNoun(IEnumerable<Lexeme> lexemes) =>
    lexemes.All(l => l.Pos == "noun");

Prevention

When it happens

Trigger: A lexeme has 'pos: verb', 'pos: adjective', or any value other than 'noun'.

Common situations: Modeling non-noun parts of speech before the engine supports them; a typo such as 'Noun' (the check is ordinal/case-sensitive).

Related errors


AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13). Data as JSON: /api/errors/af87ea25826d99ca. Report an issue: GitHub.