stanfordnlp/CoreNLP · error · IllegalArgumentException

Gabor sucks at logic and he should feel bad about it

Error message

Gabor sucks at logic and he should feel bad about it: {subjSpan} and {objSpan}

What it means

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.

Solutions

  1. Validate before calling: assert subjSpan.end() <= objSpan.start() || objSpan.end() <= subjSpan.start() (non-overlapping)
  2. Fix the mention/NER extraction stage that produced overlapping spans for subject and object
  3. Check the entity-linking/merge step that may have collapsed two mentions into one overlapping region
  4. If constructing KBPInput manually, order spans so subject precedes object, or skip examples with overlapping spans

Example fix

// before
Span subj = new Span(3, 8), obj = new Span(5, 7); // overlap → IllegalArgumentException
extractor.classify(new KBPInput(subj, obj, ...));
// after
if (subj.overlaps(obj)) return null; // skip invalid pair
extractor.classify(new KBPInput(subj, obj, ...));
Defensive patterns

Strategy: validation

Validate before calling

boolean spansOk(Span subj, Span obj) {
  return subj.end() <= obj.start() || obj.end() <= subj.start();
}

Type guard

boolean nonOverlapping(Span a, Span b) {
  return a.end() <= b.start() || b.end() <= a.start();
}

Try / catch

try {
  relation = extractor.classify(input);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("Gabor sucks")) {
    log.warn("overlapping subj/obj spans; skipping example " + input);
    relation = null;
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/abee0357ac126d03. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/ie/KBPStatisticalExtractor.java:208

  private  static <E> List<E> spanBetweenMentions(KBPInput input, Function<CoreLabel, E> selector) {
    List<CoreLabel> sentence = input.sentence.asCoreLabels(Sentence::lemmas, Sentence::nerTags);
    Span subjSpan = input.subjectSpan;
    Span objSpan = input.objectSpan;

    // Corner cases
    if (Span.overlaps(subjSpan, objSpan)) {
      return Collections.emptyList();
    }

    // Get the range between the subject and object
    int begin = subjSpan.end();
    int end = objSpan.start();
    if (begin > end) {
      begin = objSpan.end();
      end = subjSpan.start();
    }
    if (begin > end) {
      throw new IllegalArgumentException("Gabor sucks at logic and he should feel bad about it: " + subjSpan + " and " + objSpan);
    } else if (begin == end) {
      return Collections.emptyList();
    }

    // Compute the return value
    List<E> rtn = new ArrayList<>();
    for (int i = begin; i < end; ++i) {
      rtn.add(selector.apply(sentence.get(i)));
    }
    return rtn;
  }

  /**
   * <p>
   *   Span features often only make sense if the subject and object are positioned at the correct ends of the span.
   *   For example, "x is the son of y" and "y is the son of x" have the same span feature, but mean different things
   *   depending on where x and y are.
   * </p>

View on GitHub (pinned to 1b7edd19c4)