{"record":{"id":"d8759278ce7b3ee2","repo":"stanfordnlp/CoreNLP","slug":"unexpected-match-type","errorCode":null,"errorMessage":"unexpected match type","messagePattern":"unexpected match type","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/TimexTreeAnnotator.java","lineNumber":70,"sourceCode":"          // select the smallest enclosing tree\n        case SmallestEnclosing:\n          possibleMatches = Iterables.filter(tree, tree1 -> {\n            int treeBegin = beginOffset(tree, tokens);\n            int treeEnd = endOffset(tree, tokens);\n            return treeBegin <= timexBegin && timexEnd <= treeEnd;\n          });\n          List<Tree> sortedMatches = CollectionUtils.toList(possibleMatches);\n          Collections.sort(sortedMatches, (tree1, tree2) -> {\n            Integer width1 = endOffset(tree1, tokens) - beginOffset(tree1, tokens);\n            Integer width2 = endOffset(tree2, tokens) - endOffset(tree2, tokens);\n            return width1.compareTo(width2);\n          });\n          subtree = sortedMatches.get(0);\n          break;\n          \n          // more cases could go here if they're added\n        default:\n          throw new RuntimeException(\"unexpected match type\");\n        }\n  \t\n        // add the subtree to the time annotation\n        if (subtree != null) {\n          timexAnn.set(TreeCoreAnnotations.TreeAnnotation.class, subtree);\n        }\n      }\n    }\n  }\n  \n  private static int beginOffset(Tree tree, List<CoreLabel> tokens) {\n    CoreMap label = (CoreMap)tree.label();\n    int beginToken = label.get(CoreAnnotations.BeginIndexAnnotation.class);\n    return beginOffset(tokens.get(beginToken));\n  }\n  \n  private static int endOffset(Tree tree, List<CoreLabel> tokens) {\n    CoreMap label = (CoreMap)tree.label();","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/TimexTreeAnnotator.java#L52-L88","documentation":"TimexTreeAnnotator.annotate switches over the match type found when locating the TIMEX3 expression in a parse tree; the default branch throws RuntimeException 'unexpected match type' because only the handled match types are implemented. It is an exhaustiveness guard for future/unknown match types.","triggerScenarios":"Running TimexTreeAnnotator (or its main) over a corpus where the Timex-to-tree matcher returns a MatchType the annotator has no case for, e.g. match types spanning multiple subtrees that were never implemented (the comment notes 'more cases could go here').","commonSituations":"Annotating TimeBank-style documents where some TIMEX3 expressions match discontinuous or multi-node regions not covered by the implemented cases.","solutions":["Inspect which match type is produced for your corpus and add a case handling it (the comment invites adding cases)","Pre-filter documents whose TIMEX3 matches are not the supported types","Catch RuntimeException per-document and record skipped Timexes instead of aborting the run","Update the Stanford CoreNLP version, as match handling may have improved"],"exampleFix":"// before\ndefault:\n  throw new RuntimeException(\"unexpected match type\");\n// after\ndefault:\n  log.warning(\"Skipping Timex with unhandled match type: \" + matchType);\n  subtree = null;\n  break;","handlingStrategy":"try-catch","validationCode":"if (unsupportedMatchType(matchType)) { skipTimex(); }","typeGuard":null,"tryCatchPattern":"try { annotator.annotate(coreMap); } catch (RuntimeException e) { log.warn(\"skipped document: \" + e.getMessage()); }","preventionTips":["Audit which match types your corpus produces and cover them in the switch","Process documents one at a time so one bad match does not abort a batch","Keep CoreNLP updated for broader match-type coverage"],"tags":["java","annotation","parse-tree"],"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"}