stanfordnlp/CoreNLP · warning

Found a relation with a missing slot

Error message

Found a relation with a missing slot: ${p}

What it means

Same loop as the missing-entity case: if the 'slot' named node is not bound for a matched pattern, matches() warns with the pattern p and skips the candidate relation. The slot node is required to classify the relation by its index against the object span.

Solutions

  1. Name the slot node in the pattern, e.g. append '=slot' to the intended node description
  2. Audit all KBP Semgrex patterns to ensure both '=entity' and '=slot' groups exist
  3. If the group should be named differently, update both the pattern and this extractor code together
  4. Test each rule against sample sentences to confirm both nodes bind

Example fix

// before
String p = "{word:CEO}=entity <<apposition {tag:/NN.*/}";
// after
String p = "{word:CEO}=entity <<apposition {tag:/NN.*/}=slot";
Defensive patterns

Strategy: validation

Validate before calling

if (!pattern.contains("=slot")) throw new IllegalArgumentException("pattern missing =slot: " + pattern);

Try / catch

SemgrexMatcher m = p.matcher(graph);
while (m.find()) {
  IndexedWord slot = m.getNode("slot");
  if (slot == null) { log.warn("no slot for " + pattern); continue; }
  // ...
}

Prevention

When it happens

Trigger: A Semgrex KBP rule that binds 'entity' but not 'slot', or binds slot only on some branches, so certain matches reach getNode("slot") returning null.

Common situations: Incomplete rule edits; patterns refactored where the '=slot' naming was dropped; copied patterns using different group names like '=object'.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/ie/KBPSemgrexExtractor.java:125

      if ("O".equals(tokens.get(i).ner())) {
        tokens.get(i).setNER(input.objectType.name);
      }
    }

    for (SemgrexPattern p : rulesForRel) {

      SemgrexMatcher n = p.matcher(graph);
      while (n.find()) {
        IndexedWord entity = n.getNode("entity");
        IndexedWord slot = n.getNode("slot");
        if (entity == null) {
          // really this is a hideous bug, right?  these rules
          // should all have entity and slot set
          logger.warn("Found a relation with a missing entity: " + p);
          continue;
        }
        if (slot == null) {
          logger.warn("Found a relation with a missing slot: " + p);
          continue;
        }
        boolean hasSubject = entity.index() >= input.subjectSpan.start() + 1 && entity.index() <= input.subjectSpan.end();
        boolean hasObject  = slot.index() >= input.objectSpan.start() + 1 && slot.index() <= input.objectSpan.end();
        
        if (hasSubject && hasObject) {
          return p;
        } 
      }
    }
    return null;
  }


  public static void main(String[] args) throws IOException {
    RedwoodConfiguration.standard().apply();  // Disable SLF4J crap.
    ArgumentParser.fillOptions(KBPSemgrexExtractor.class, args);
    KBPSemgrexExtractor extractor = new KBPSemgrexExtractor(DIR);

View on GitHub (pinned to 1b7edd19c4)