{"record":{"id":"abee0357ac126d03","repo":"stanfordnlp/CoreNLP","slug":"gabor-sucks-at-logic-and-he-should-feel-bad-about","errorCode":null,"errorMessage":"Gabor sucks at logic and he should feel bad about it: {subjSpan} and {objSpan}","messagePattern":"Gabor sucks at logic and he should feel bad about it: (.+?) and (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/KBPStatisticalExtractor.java","lineNumber":208,"sourceCode":"  private  static <E> List<E> spanBetweenMentions(KBPInput input, Function<CoreLabel, E> selector) {\n    List<CoreLabel> sentence = input.sentence.asCoreLabels(Sentence::lemmas, Sentence::nerTags);\n    Span subjSpan = input.subjectSpan;\n    Span objSpan = input.objectSpan;\n\n    // Corner cases\n    if (Span.overlaps(subjSpan, objSpan)) {\n      return Collections.emptyList();\n    }\n\n    // Get the range between the subject and object\n    int begin = subjSpan.end();\n    int end = objSpan.start();\n    if (begin > end) {\n      begin = objSpan.end();\n      end = subjSpan.start();\n    }\n    if (begin > end) {\n      throw new IllegalArgumentException(\"Gabor sucks at logic and he should feel bad about it: \" + subjSpan + \" and \" + objSpan);\n    } else if (begin == end) {\n      return Collections.emptyList();\n    }\n\n    // Compute the return value\n    List<E> rtn = new ArrayList<>();\n    for (int i = begin; i < end; ++i) {\n      rtn.add(selector.apply(sentence.get(i)));\n    }\n    return rtn;\n  }\n\n  /**\n   * <p>\n   *   Span features often only make sense if the subject and object are positioned at the correct ends of the span.\n   *   For example, \"x is the son of y\" and \"y is the son of x\" have the same span feature, but mean different things\n   *   depending on where x and y are.\n   * </p>","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/KBPStatisticalExtractor.java#L190-L226","documentation":"KBPStatisticalExtractor.spanBetweenMentions extracts the tokens between subject and object spans. If the two spans overlap or are positioned such that no valid 'between' range exists even after swapping, the spans are nonsensical and it throws an IllegalArgumentException (with a joking message) instead of returning bad features.","triggerScenarios":"Calling classify/extract features on a KBPInput whose subject and object spans overlap or where subject.end() > object.start() AND subject.start() > object.end() — i.e. neither ordering yields begin <= end.","commonSituations":"Bugs in upstream mention-detection producing overlapping subject/object spans; training/test data with corrupted span indices; passing hand-constructed Span objects with inverted start/end.","solutions":["Validate before calling: assert subjSpan.end() <= objSpan.start() || objSpan.end() <= subjSpan.start() (non-overlapping)","Fix the mention/NER extraction stage that produced overlapping spans for subject and object","Check the entity-linking/merge step that may have collapsed two mentions into one overlapping region","If constructing KBPInput manually, order spans so subject precedes object, or skip examples with overlapping spans"],"exampleFix":"// before\nSpan subj = new Span(3, 8), obj = new Span(5, 7); // overlap → IllegalArgumentException\nextractor.classify(new KBPInput(subj, obj, ...));\n// after\nif (subj.overlaps(obj)) return null; // skip invalid pair\nextractor.classify(new KBPInput(subj, obj, ...));","handlingStrategy":"validation","validationCode":"boolean spansOk(Span subj, Span obj) {\n  return subj.end() <= obj.start() || obj.end() <= subj.start();\n}","typeGuard":"boolean nonOverlapping(Span a, Span b) {\n  return a.end() <= b.start() || b.end() <= a.start();\n}","tryCatchPattern":"try {\n  relation = extractor.classify(input);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Gabor sucks\")) {\n    log.warn(\"overlapping subj/obj spans; skipping example \" + input);\n    relation = null;\n  } else throw e;\n}","preventionTips":["Filter KBPInput pairs with overlapping subject/object spans before feature extraction","Fix mention-detection offsets (char-index off-by-one bugs cause overlaps)","Validate Span invariants start <= end at construction time"],"tags":["java","corenlp","kbp","span-validation"],"backgroundTag":"invalid-argument-value","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"}