stanfordnlp/CoreNLP · error · UnsupportedOperationException
Dependencies type not implemented
Error message
Dependencies type not implemented: <commandArgs>
What it means
LexicalizedParserServer.handleDependencies() only implements the COLLAPSED_TREE dependencies type; any other command argument hits the switch default and throws UnsupportedOperationException. The server exposes just one dependency-output flavor for this endpoint.
Solutions
- Send exactly COLLAPSED_TREE as the dependencies type argument.
- Upgrade both client and server to a CoreNLP version supporting the dependency format you need.
- Compute other dependency styles client-side from a parsed tree (typedDependencies in your own code).
- Patch/extend handleDependencies in a local fork if you need additional formats.
Example fix
// before
String resp = client.query("deps", "basic", sentence);
// after
String resp = client.query("deps", "COLLAPSED_TREE", sentence); Defensive patterns
Strategy: validation
Validate before calling
if (!"COLLAPSED_TREE".equalsIgnoreCase(depsType))
throw new IllegalArgumentException("Server supports only COLLAPSED_TREE deps type, got: " + depsType); Try / catch
try {
String resp = client.query("deps", depsType, sentence);
} catch (UnsupportedOperationException e) {
if (e.getMessage().startsWith("Dependencies type not implemented")) {
// fall back to COLLAPSED_TREE
}
} Prevention
- Hard-code the argument as COLLAPSED_TREE.
- Derive other dependency styles client-side from the returned tree.
- Verify server version before relying on newer dep formats.
When it happens
Trigger: Sending a server request 'deps' (or similar) with a commandArgs value other than COLLAPSED_TREE, e.g. 'TREE', 'COLLAPSED', 'BASIC', or a lowercase-variant bug (uppercase conversion is applied, so casing is fine).
Common situations: Clients built against newer CoreNLP APIs (which support basic/collapsed/semicolon formats) talking to an older server, or guessing argument names not in the switch.
Related errors
- : Does not support parse operation.
- Cannot set from string
- Cannot set from string
- This version of the parser does not support non-tree…
- This version of the parser does not support non-tree…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/e0c0eb98f5e0ed82.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/server/LexicalizedParserServer.java:229
// TODO: when this method throws an exception (for whatever reason)
// a waiting client might hang. There should be some graceful
// handling of that.
public void handleDependencies(String arg, OutputStream outStream, String commandArgs)
throws IOException
{
Tree tree = parse(arg, false);
if (tree == null) {
return;
}
// TODO: this might throw an exception if the parser doesn't support dependencies. Handle that cleaner?
GrammaticalStructure gs = parser.getTLPParams().getGrammaticalStructure(tree, parser.treebankLanguagePack().punctuationWordRejectFilter(), parser.getTLPParams().typedDependencyHeadFinder());
Collection<TypedDependency> deps = null;
switch (commandArgs.toUpperCase()) {
case "COLLAPSED_TREE":
deps = gs.typedDependenciesCollapsedTree();
break;
default:
throw new UnsupportedOperationException("Dependencies type not implemented: " + commandArgs);
}
OutputStreamWriter osw = new OutputStreamWriter(outStream, "utf-8");
for (TypedDependency dep : deps) {
osw.write(dep.toString());
osw.write("\n");
}
osw.flush();
}
/**
* Returns the result of applying the parser to arg as a serialized tree.
*/
public void handleTree(String arg, OutputStream outStream)
throws IOException
{
Tree tree = parse(arg, false);
if (tree == null) {
return;View on GitHub (pinned to 1b7edd19c4)