{"record":{"id":"7e559e7282d10558","repo":"stanfordnlp/CoreNLP","slug":"too-many-timexes-for-str","errorCode":null,"errorMessage":"Too many timexes for '${str}'","messagePattern":"Too many timexes for '(.+?)'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/SUTimeSimpleParser.java","lineNumber":108,"sourceCode":"      return timex.get(TimeExpression.Annotation.class).getTemporal();\n    }\n  }\n\n  /**\n   * Parse a string with SUTime.\n   *\n   * @throws SUTimeParsingError if anything goes wrong\n   */\n  public static Temporal parse(String str) throws SUTimeParsingError {\n    try {\n      Annotation doc = new Annotation(str);\n      pipeline.annotate(doc);\n\n      assert doc.get(CoreAnnotations.SentencesAnnotation.class) != null;\n      assert ! doc.get(CoreAnnotations.SentencesAnnotation.class).isEmpty();\n      List<CoreMap> timexAnnotations = doc.get(TimeAnnotations.TimexAnnotations.class);\n      if (timexAnnotations.size() > 1) {\n        throw new RuntimeException(\"Too many timexes for '\" + str + '\\'');\n      }\n      CoreMap timex = timexAnnotations.get(0);\n\n      return timex.get(TimeExpression.Annotation.class).getTemporal();\n    } catch (Exception e) {\n      SUTimeSimpleParser.SUTimeParsingError parsingError = new SUTimeSimpleParser.SUTimeParsingError(str);\n      parsingError.initCause(e);\n      throw parsingError;\n    }\n  }\n\n  /**\n   * Cached wrapper of parse method.\n   */\n  public static Temporal parseUsingCache(String str) throws SUTimeParsingError {\n    calls++;\n    if (!cache.containsKey(str)) {\n      misses++;","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/SUTimeSimpleParser.java#L90-L126","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nSUTime.Temporal t = SUTimeSimpleParser.parse(str);\n// after\ntry {\n  SUTime.Temporal t = SUTimeSimpleParser.parse(str);\n} catch (SUTimeSimpleParser.SUTimeParsingError e) {\n  // handle multi-timex or unparseable input\n}\n","handlingStrategy":"try-catch","validationCode":"// Pre-check with the full pipeline: only call simple parser when a single TimexAnnotations is returned\npipeline.annotate(doc);\nList<CoreMap> timexes = doc.get(TimeAnnotations.TimexAnnotations.class);\nboolean safeToParse = timexes != null && timexes.size() == 1;","typeGuard":null,"tryCatchPattern":"try { temporal = SUTimeSimpleParser.parseUsingCache(str); } catch (SUTimeSimpleParser.SUTimeParsingError e) { /* fall back to full TimeAnnotator pipeline or manual parsing */ }","preventionTips":["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"],"tags":["java","sutime","parsing","nlp"],"backgroundTag":"unexpected-response-shape","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}