stanfordnlp/CoreNLP · error · RuntimeException

Invalid language setting: cannot load HeadFinder

Error message

Invalid language setting: cannot load HeadFinder

What it means

Thrown by CorefProperties.getHeadFinder when the configured coref language resolves to a locale for which no HeadFinder implementation is wired up (only English and Chinese have mappings); indicates an unsupported coref.language setting for parsing head rules.

Solutions

  1. Fix coref.language so it resolves to English or Chinese
  2. Provide a custom HeadFinder if extending to other languages
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/edu/stanford/nlp/coref/CorefProperties.java:198 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/5eb6479e3e309dac. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/coref/CorefProperties.java:198

    if (lang.equalsIgnoreCase("en") || lang.equalsIgnoreCase("english")) {
      return Locale.ENGLISH;
    } else if(lang.equalsIgnoreCase("zh") || lang.equalsIgnoreCase("chinese")) {
      return Locale.CHINESE;
    } else {
      throw new IllegalArgumentException("unsupported language");
    }
  }

  private static String getLanguageStr(Properties props) {
    return getLanguage(props).getDisplayName().toLowerCase();
  }

  public static HeadFinder getHeadFinder(Properties props) {
    Locale lang = getLanguage(props);
    if (lang == Locale.ENGLISH) return new SemanticHeadFinder();
    else if (lang == Locale.CHINESE) return new ChineseSemanticHeadFinder();
    else {
      throw new RuntimeException("Invalid language setting: cannot load HeadFinder");
    }
  }

  public static Predicate<Pair<CorefChain.CorefMention, List<CoreLabel>>> getCorefMentionFilter(Properties props) {
    String filterCorefChain = props.getProperty("coref.evaluate.filter");
    if (filterCorefChain != null) {
        if ("filterCustomerAbstractPronouns".equals(filterCorefChain)) {
            return CorefUtils.filterCustomerAbstractPronouns;
        } else {
            throw new RuntimeException("Cannot create coref.evaluate.filter " + filterCorefChain);
        }
    } else {
        return null;
    }
  }
}

View on GitHub (pinned to 1b7edd19c4)