{"record":{"id":"a808d44d3e93eb18","repo":"stanfordnlp/CoreNLP","slug":"match-failed","errorCode":null,"errorMessage":"Match failed!","messagePattern":"Match failed!","errorType":"exception","errorClass":"MatchException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/machinereading/domains/ace/reader/AceCharSeq.java","lineNumber":153,"sourceCode":"      }\n\n      //\n      // we do not tokenize dashed-words, hence the end may be inside a token\n      // e.g. Conference => Conference-leading\n      // the same situation will happen due to (uncommon) annotation errors\n      //\n      else if (mByteOffset.end() >= tokens.get(i).getByteOffset().start()\n          && mByteOffset.end() < tokens.get(i).getByteOffset().end() - 1) {\n        end = i;\n        break;\n      }\n    }\n\n    if (start >= 0 && end >= 0) {\n      mTokenOffset = new Span(start, end);\n      // mPhrase = makePhrase(tokens, mTokenOffset);\n    } else {\n      throw new MatchException(\"Match failed!\");\n    }\n  }\n\n  @Override\n  public String toString() {\n    return \"AceCharSeq [mByteOffset=\" + mByteOffset + \", mText=\" + mText\n        + \", mTokenOffset=\" + mTokenOffset + ']';\n  }\n\n  /*\n   * private AceToken makePhrase(Vector<AceToken> tokens, Span span) {\n   * StringBuilder word = new StringBuilder(); StringBuilder lemma = new\n   * StringBuilder(); StringBuilder pos = new StringBuilder(); StringBuilder chunk =\n   * new StringBuilder(); StringBuilder nerc = new StringBuilder();\n   *\n   * for(int i = span.mStart; i <= span.mEnd; i ++){ if(i > span.mStart){\n   * word.append(\"_\"); lemma.append(\"_\"); pos.append(\"_\"); chunk.append(\"_\");\n   * nerc.append(\"_\"); }","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/machinereading/domains/ace/reader/AceCharSeq.java#L135-L171","documentation":"AceCharSeq.match() attempts to locate an entity's character extent within a token stream and record the resulting token Span. If both start and end are not found (negative), it throws MatchException('Match failed!'), meaning the ACE entity extent could not be aligned to any tokens.","triggerScenarios":"Parsing ACE 2005 .apf.xml files where an entity/extent's start/end offsets do not fall within the tokenized document — typically when the .apf annotation offsets disagree with the .sgm source text (e.g. mismatched file pair, wrong docId, or extents referencing text not in the tokens list).","commonSituations":"Mismatched or incomplete ACE corpus files, annotation offsets counted in bytes vs characters when non-ASCII text is present, feeding the reader a .sgm with preprocessing that stripped characters the offsets refer to.","solutions":["Ensure the .apf.xml and .sgm files are a matching pair from the same document.","Verify offsets are character offsets consistent with the exact source text handed to the tokenizer (watch for XML entity vs raw character offsets).","Skip or log documents/entities whose extents fall outside tokens instead of failing the whole parse.","Re-run corpus preprocessing so tokens cover the full extent range."],"exampleFix":"// before\nfor (String doc : docs) reader.parse(doc);\n// after\ntry {\n  reader.parse(doc);\n} catch (MatchException e) {\n  logger.warning(\"skipping unmatchable document: \" + doc);\n}","handlingStrategy":"try-catch","validationCode":"if (extentStart < 0 || extentEnd >= docText.length()) {\n  logger.warning(\"extent out of bounds, skipping: \" + docId);\n  return;\n}","typeGuard":null,"tryCatchPattern":"try {\n  reader.parseDocument(docId);\n} catch (MatchException e) {\n  logger.warning(\"token alignment failed for \" + docId + \": \" + e.getMessage());\n}","preventionTips":["Keep .apf.xml and .sgm pairs matched from the same ACE release.","Beware byte vs character offsets with non-ASCII source text.","Log-and-skip unmatchable entities instead of aborting corpus reads."],"tags":["java","stanford-nlp","ace-corpus","parsing"],"backgroundTag":"entity-not-found","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}