stanfordnlp/CoreNLP · error · UnsupportedOperationException
PREV_IMMEDIATE not implemented for arg1=
Error message
PREV_IMMEDIATE not implemented for arg1=${arg1.getClass()}, arg2=${arg2.getClass()} What it means
TemporalOp.PREV_IMMEDIATE ('this past Friday') resolves arg2 to the immediately preceding instance relative to arg1, which must be a Time. A non-Time arg1 has no implemented semantics, so UnsupportedOperationException is thrown naming both argument classes.
Solutions
- Convert or resolve arg1 to a SUTime.Time before applying the operator
- Use the class names in the message to locate and fix the offending rule/call site
- Guard with instanceof Time and provide an explicit alternative path
- Upgrade or file an issue with CoreNLP if triggered by a built-in rule
Example fix
// before
TemporalOp.PREV_IMMEDIATE.apply(arg1, arg2, flags);
// after
if (!(arg1 instanceof Time)) { arg1 = arg1.getRange().end(); }
TemporalOp.PREV_IMMEDIATE.apply(arg1, arg2, flags);
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(arg1 instanceof SUTime.Time)) { throw new IllegalArgumentException("PREV_IMMEDIATE requires arg1 to be a Time"); } Type guard
boolean canApplyPrevImmediate(SUTime.Temporal arg1) { return arg1 instanceof SUTime.Time; } Try / catch
try { result = TemporalOp.PREV_IMMEDIATE.apply(arg1, arg2, flags); } catch (UnsupportedOperationException e) { /* convert arg1 via getRange().end() and retry */ } Prevention
- Ensure reference times parse as Time for 'this past X' phrases
- Add instanceof checks around TemporalOp dispatch
- Keep rule tests covering immediate past expressions
When it happens
Trigger: Calling SUTime.TemporalOp.PREV_IMMEDIATE.apply(arg1, arg2, flags) where arg1 is a Duration/Range rather than a Time, usually from custom temporal rules.
Common situations: Parsing 'this past week' phrases where the reference date was mis-parsed; incorrect argument ordering in code that drives TemporalOp directly.
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
- NEXT not implemented for arg1=
- NEXT_IMMEDIATE not implemented for arg1=
- THIS not implemented for arg1=
- PREV not implemented for arg1=
- Type mismatch on arg0: Cannot apply
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/e7ae2d49b45953f6.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/time/SUTime.java:1123
// if (arg1 == null || arg2Prev == null) { return arg2Prev; }
if (arg1 instanceof Time) {
Time t = (Time) arg1;
if (arg2 instanceof Duration) {
return ((Duration) arg2).toTime(t, flags | RESOLVE_TO_PAST);
} else {
// TODO: flags?
Temporal resolvedThis = arg2.resolve(t, RESOLVE_TO_PAST);
if (resolvedThis != null) {
if (resolvedThis instanceof Time) {
if (((Time) resolvedThis).compareTo(t) >= 0) {
return PREV.apply(arg1, arg2);
}
}
}
return resolvedThis;
}
} else {
throw new UnsupportedOperationException("PREV_IMMEDIATE not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass());
}
}
},
UNION {
@Override
public Temporal apply(Temporal arg1, Temporal arg2, int flags) {
if (arg1 == null) {
return arg2;
}
if (arg2 == null) {
return arg1;
}
// return arg1.union(arg2);
throw new UnsupportedOperationException("UNION not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass());
}
},
INTERSECT {
@OverrideView on GitHub (pinned to 1b7edd19c4)