stanfordnlp/CoreNLP · error · RuntimeException
Too many timexes for
Error message
Too many timexes for '${str}' What it means
SUTimeSimpleParser.parse runs the full SUTime pipeline over a short string and expects exactly one time expression. If the annotated document yields more than one timex, it throws RuntimeException 'Too many timexes'. The library wraps this (and other failures) into a SUTimeParsingError, so callers usually see the wrapped form.
Solutions
- Catch SUTimeParsingError and fall back to another parsing strategy for multi-timex strings
- Pre-normalize the input (split or rewrite the string) so it contains a single time expression
- Adjust SUTime rules/properties so the phrase is parsed as one expression, or use the full TimeAnnotator pipeline instead of the simple parser
- Check CoreNLP version — newer rule sets may parse the phrase as a single timex
Example fix
// before
SUTime.Temporal t = SUTimeSimpleParser.parse(str);
// after
try {
SUTime.Temporal t = SUTimeSimpleParser.parse(str);
} catch (SUTimeSimpleParser.SUTimeParsingError e) {
// handle multi-timex or unparseable input
}
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check with the full pipeline: only call simple parser when a single TimexAnnotations is returned pipeline.annotate(doc); List<CoreMap> timexes = doc.get(TimeAnnotations.TimexAnnotations.class); boolean safeToParse = timexes != null && timexes.size() == 1;
Try / catch
try { temporal = SUTimeSimpleParser.parseUsingCache(str); } catch (SUTimeSimpleParser.SUTimeParsingError e) { /* fall back to full TimeAnnotator pipeline or manual parsing */ } Prevention
- Only use SUTimeSimpleParser on strings expected to contain one time expression
- Catch SUTimeParsingError (it wraps the raw RuntimeException)
- Pre-normalize composite date-time strings before parsing
- Prefer the full TimeAnnotator pipeline for arbitrary text
When it happens
Trigger: Calling SUTimeSimpleParser.parse (or parseUsingCache) on a natural-language string that SUTime recognizes as two or more separate temporal expressions, e.g. 'January 3, 2011 3:30pm' or 'Monday to Friday', where only a single temporal is expected.
Common situations: Parsing composite date-time strings from user input or web text; ambiguity from SUTime rules splitting a phrase into two TIMEX3 tags; version differences in SUTime rules changing how a phrase is segmented.
Related errors
- Bad number put into wordToNumber. Word is: \"" + input +…
- Error in wordToNumber function.
- Bad number put into wordToNumber. Word is: \"" + curPart +…
- Doesn't do k best yet
- Doesn't do best parses yet
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/7e559e7282d10558.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/time/SUTimeSimpleParser.java:108
return timex.get(TimeExpression.Annotation.class).getTemporal();
}
}
/**
* Parse a string with SUTime.
*
* @throws SUTimeParsingError if anything goes wrong
*/
public static Temporal parse(String str) throws SUTimeParsingError {
try {
Annotation doc = new Annotation(str);
pipeline.annotate(doc);
assert doc.get(CoreAnnotations.SentencesAnnotation.class) != null;
assert ! doc.get(CoreAnnotations.SentencesAnnotation.class).isEmpty();
List<CoreMap> timexAnnotations = doc.get(TimeAnnotations.TimexAnnotations.class);
if (timexAnnotations.size() > 1) {
throw new RuntimeException("Too many timexes for '" + str + '\'');
}
CoreMap timex = timexAnnotations.get(0);
return timex.get(TimeExpression.Annotation.class).getTemporal();
} catch (Exception e) {
SUTimeSimpleParser.SUTimeParsingError parsingError = new SUTimeSimpleParser.SUTimeParsingError(str);
parsingError.initCause(e);
throw parsingError;
}
}
/**
* Cached wrapper of parse method.
*/
public static Temporal parseUsingCache(String str) throws SUTimeParsingError {
calls++;
if (!cache.containsKey(str)) {
misses++;View on GitHub (pinned to 1b7edd19c4)