stanfordnlp/CoreNLP · error · UnsupportedOperationException
Doesn't do k good yet
Error message
Doesn't do k good yet
What it means
An UnsupportedOperationException stub in ExhaustiveDependencyParser.getBestParses: this dependency parser only produces a single best parse, so requests for k-best/good parse lists are rejected as unimplemented.
Solutions
- Switch to a parser that maintains n-good lists such as FastFactoredParser or ExhaustivePCFGParser.
- Catch UnsupportedOperationException and return the single best parse instead.
- Request only one parse via getBestParse() when using the dependency parser.
Example fix
// before
List<ScoredObject<Tree>> good = pq.getKGoodParses(5);
// after
List<ScoredObject<Tree>> good;
try {
good = pq.getKGoodParses(5);
} catch (UnsupportedOperationException e) {
good = Collections.singletonList(new ScoredObject<>(pq.getBestParse(), pq.getBestScore()));
} Defensive patterns
Strategy: try-catch
Validate before calling
boolean supportsKGood = query.getClass().getSimpleName().contains("PCFG") || query.getClass().getSimpleName().contains("FastFactored"); Try / catch
try { good = pq.getKGoodParses(k); } catch (UnsupportedOperationException e) { good = Collections.singletonList(new ScoredObject<>(pq.getBestParse(), pq.getBestScore())); } Prevention
- Only request k-good parses from parsers documented to support them.
- Prefer getBestParse() for dependency parsing.
- Add unit tests covering all parser implementations your app selects.
When it happens
Trigger: Calling getKGoodParses(k) with any k on a ParserQuery created by ExhaustiveDependencyParser.
Common situations: Generic code iterating over a list of parsers and requesting k-good parse approximations; dependency parser does not maintain n-best lists.
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
- Doesn't do k best yet
- Doesn't do best parses yet
- Doesn't do k sampled yet
- ExhaustivePCFGParser doesn't sample.
- FastFactoredParser: cannot provide k good parses.
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/926f79f8167bcbe8.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/lexparser/ExhaustiveDependencyParser.java:846
*/
@Override
public List<ScoredObject<Tree>> getBestParses() {
throw new UnsupportedOperationException("Doesn't do best parses yet");
}
/** Get k good parses for the sentence. It is expected that the
* parses returned approximate the k best parses, but without any
* guarantee that the exact list of k best parses has been produced.
* If a class really provides k best parses functionality, it is
* reasonable to also return this output as the k good parses.
*
* @param k The number of good parses to return
* @return A list of k good parses for the sentence, with
* each accompanied by its score
*/
@Override
public List<ScoredObject<Tree>> getKGoodParses(int k) {
throw new UnsupportedOperationException("Doesn't do k good yet");
}
/** Get k parse samples for the sentence. It is expected that the
* parses are sampled based on their relative probability.
*
* @param k The number of sampled parses to return
* @return A list of k parse samples for the sentence, with
* each accompanied by its score
*/
@Override
public List<ScoredObject<Tree>> getKSampledParses(int k) {
throw new UnsupportedOperationException("Doesn't do k sampled yet");
}
}
View on GitHub (pinned to 1b7edd19c4)