stanfordnlp/CoreNLP · error · RuntimeException

LogPrior.getSigmaSquaredM is undefined for any prior but…

Error message

LogPrior.getSigmaSquaredM is undefined for any prior but MULTIPLE_QUADRATIC

What it means

LogPrior.getSigmaSquaredM() returns the per-dimension sigma-squared vector, which is only maintained for the MULTIPLE_QUADRATIC prior. For any other prior type the field is uninitialized, so the method throws a RuntimeException rather than returning meaningless data. The message also includes the prior's toString.

Solutions

  1. Only call getSigmaSquaredM() when getPriorType() == LogPriorType.MULTIPLE_QUADRATIC
  2. For simple priors use getSigma()/getEpsilon() accessors appropriate to the prior type
  3. Wrap the call in a type check and use a different estimation for other priors

Example fix

// before
double[] sig = prior.getSigmaSquaredM();
// after
if (prior.getPriorType() == LogPrior.LogPriorType.MULTIPLE_QUADRATIC) {
  double[] sig = prior.getSigmaSquaredM();
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (prior.getPriorType() != LogPrior.LogPriorType.MULTIPLE_QUADRATIC)
  throw new IllegalStateException("getSigmaSquaredM requires MULTIPLE_QUADRATIC prior");

Type guard

boolean supportsSigmaVector(LogPrior p) {
  return p.getPriorType() == LogPrior.LogPriorType.MULTIPLE_QUADRATIC;
}

Try / catch

try {
  double[] s = prior.getSigmaSquaredM();
} catch (RuntimeException e) {
  // fall back to scalar sigma for simple priors
  double sigma = prior.getSigma();
}

Prevention

When it happens

Trigger: Calling getSigmaSquaredM() on a LogPrior whose type is NULL, QUADRATIC, HUBER, QUARTIC, COSH, or ADAPT instead of MULTIPLE_QUADRATIC — e.g., from sigmaSquaredOld() or user code inspecting the prior.

Common situations: Code written generically over priors assuming a sigma vector always exists; switching a training config from multiple-quadratic to huber/quadratic while diagnostics still read getSigmaSquaredM().

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/classify/LogPrior.java:143

      return otherPrior.getSigma();
    } else {
      return Math.sqrt(sigmaSq);
    }
  }

  public double getSigmaSquared() {
    if (type == LogPriorType.ADAPT) {
      return otherPrior.getSigmaSquared();
    } else {
      return sigmaSq;
    }
  }

  public double[] getSigmaSquaredM() {
    if (type == LogPriorType.MULTIPLE_QUADRATIC) {
      return sigmaSqM;
    } else {
      throw new RuntimeException("LogPrior.getSigmaSquaredM is undefined for any prior but MULTIPLE_QUADRATIC" + this);
    }
  }


  public double getEpsilon() {
    if (type == LogPriorType.ADAPT) {
      return otherPrior.getEpsilon();
    } else {
      return epsilon;
    }
  }

  public void setSigma(double sigma) {
    if (type == LogPriorType.ADAPT) { otherPrior.setSigma(sigma); }
    else {
//    this.sigma = sigma;
      this.sigmaSq = sigma * sigma;
      this.sigmaQu = sigmaSq * sigmaSq;

View on GitHub (pinned to 1b7edd19c4)