stanfordnlp/CoreNLP · error · IllegalArgumentException

Unknown style

Error message

Unknown style: ${style}

What it means

IllegalArgumentException from LinearClassifier.toString(style, param) when the style string matches none of the supported names (HighWeight, HighMagnitude, etc.). It is a formatting-dispatch guard for human-readable classifier dumps.

Solutions

  1. Use a supported style string such as HighWeight or HighMagnitude
  2. Pass null or empty for the default summary output
  3. Check the style value's spelling and case (comparison is case-insensitive but the name must match)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/edu/stanford/nlp/classify/LinearClassifier.java:830 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/28cac84dfd5a381a. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/classify/LinearClassifier.java:830

   * @throws IllegalArgumentException if the style name is unrecognized
   */
  public String toString(String style, int param) {
    if (style == null || style.isEmpty()) {
      return "LinearClassifier with " + featureIndex.size() + " features, " +
              labelIndex.size() + " classes, and " +
              labelIndex.size() * featureIndex.size() + " parameters.\n";
    } else if (style.equalsIgnoreCase("HighWeight")) {
      return toBiggestWeightFeaturesString(false, param, true);
    } else if (style.equalsIgnoreCase("HighMagnitude")) {
      return toBiggestWeightFeaturesString(true, param, true);
    } else if (style.equalsIgnoreCase("AllWeights")) {
      return toAllWeightsString();
    } else if (style.equalsIgnoreCase("WeightHistogram")) {
      return toHistogramString();
    } else if (style.equalsIgnoreCase("WeightDistribution")) {
      return toDistributionString(param);
    } else {
      throw new IllegalArgumentException("Unknown style: " + style);
    }
  }


  /**
   * Convert parameter value into number between 0 and 201
   */
  private static int bucketizeValue(double wt) {
    int index;
    if (wt >= 0.0) {
      index = ((int) (wt * 10.0)) + 100;
    } else {
      index = ((int) (Math.floor(wt * 10.0))) + 100;
    }
    if (index < 0) {
      index = 201;
    } else if (index > 200) {
      index = 200;

View on GitHub (pinned to 1b7edd19c4)