stanfordnlp/CoreNLP · error · UnsupportedOperationException
Not yet implemented
Error message
Not yet implemented
What it means
The SentimentModel constructor derives binary grammar productions from the options. When op.simplifiedModel is false, the constructor is supposed to scan the training trees for actual constituent labels, but that logic was never implemented, so it throws UnsupportedOperationException.
Solutions
- Set op.simplifiedModel = true so the constructor uses the single "" binary production
- Implement the missing logic yourself (extract binary productions from the trees) if non-simplified mode is required
Example fix
// before RNNOptions op = new RNNOptions(); op.simplifiedModel = false; SentimentModel model = new SentimentModel(op, trainingTrees); // throws // after RNNOptions op = new RNNOptions(); op.simplifiedModel = true; SentimentModel model = new SentimentModel(op, trainingTrees);
Defensive patterns
Strategy: validation
Validate before calling
if (!op.simplifiedModel) {
throw new IllegalStateException("SentimentModel constructor only supports simplifiedModel=true");
}
SentimentModel model = new SentimentModel(op, trainingTrees); Try / catch
try {
model = new SentimentModel(op, trainingTrees);
} catch (UnsupportedOperationException e) {
op.simplifiedModel = true;
model = new SentimentModel(op, trainingTrees);
} Prevention
- Keep op.simplifiedModel = true for sentiment models
- Read the TODO comments in SentimentModel before enabling non-simplified modes
- Treat non-simplified sentiment options as unsupported; enforce in your config loader
When it happens
Trigger: Constructing a SentimentModel (via new SentimentModel(op, trainingTrees) or similar) with RNNOptions.simplifiedModel set to false.
Common situations: Running sentiment training on custom data with non-simplified options, expecting constituent-label support that the sentiment model never implemented; adapting the model to constituency-labelled trees.
Related errors
- Can only create a model using this method if…
- Cannot create random word vectors for an unknown numHid
- Unknown word vector not specified in the word vector file
- Not sure if RVFDataset runs correctly in this method…
- minValue for feature
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/267716c7a3a6a4ed.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/sentiment/SentimentModel.java:303
this.numHid = op.numHid;
} else {
int size = 0;
for (SimpleMatrix vector : wordVectors.values()) {
size = vector.getNumElements();
break;
}
this.numHid = size;
}
TwoDimensionalSet<String, String> binaryProductions = TwoDimensionalSet.hashSet();
if (op.simplifiedModel) {
binaryProductions.add("", "");
} else {
// TODO
// figure out what binary productions we have in these trees
// Note: the current sentiment training data does not actually
// have any constituent labels
throw new UnsupportedOperationException("Not yet implemented");
}
Set<String> unaryProductions = Generics.newHashSet();
if (op.simplifiedModel) {
unaryProductions.add("");
} else {
// TODO
// figure out what unary productions we have in these trees (preterminals only, after the collapsing)
throw new UnsupportedOperationException("Not yet implemented");
}
this.numClasses = op.numClasses;
identity = SimpleMatrix.identity(numHid);
binaryTransform = TwoDimensionalMap.treeMap();
binaryTensors = TwoDimensionalMap.treeMap();
binaryClassification = TwoDimensionalMap.treeMap();View on GitHub (pinned to 1b7edd19c4)