stanfordnlp/CoreNLP · error · RuntimeException

Unknown index " " in dictionary " "!

Error message

Unknown index "${idx}" in dictionary "${mName}"!

What it means

RuntimeException from StringDictionary.get(int) when the integer index has no reverse mapping in the dictionary (and is not the -1 NIL sentinel); the caller passed an index outside the dictionary's populated range.

Solutions

  1. Use getCount/-1 sentinel checks before reverse lookups
  2. Ensure the index came from the same dictionary instance that assigned it
  3. Reload or rebuild the dictionary if it was truncated
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/edu/stanford/nlp/ie/machinereading/common/StringDictionary.java:112 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src/edu/stanford/nlp/ie/machinereading/common/StringDictionary.java:112

    if (shouldThrow) {
      throw new RuntimeException("Unknown entry \"" + s + "\" in dictionary \"" + mName + "\"!");
    } else {
      return -1;
    }
  }

  public static final String NIL_VALUE = "nil";

  /**
   * Reverse mapping from integer key to string value
   */
  public String get(int idx) {
    if (idx == -1)
      return NIL_VALUE;

    String s = mInverse.get(idx);
    if (s == null)
      throw new RuntimeException("Unknown index \"" + idx + "\" in dictionary \"" + mName + "\"!");
    return s;
  }

  public int getCount(int idx) {
    if (idx == -1)
      return 0;

    String s = mInverse.get(idx);
    if (s == null)
      throw new RuntimeException("Unknown index \"" + idx + "\" in dictionary \"" + mName + "\"!");

    return getIndexAndCount(s).mCount;
  }

  /**
   * Saves all dictionary entries that appeared {@literal >} threshold times Note: feature
   * indices are changed to contiguous values starting at 0. This is needed in
   * order to minimize the memory allocated for the expanded feature vectors

View on GitHub (pinned to 1b7edd19c4)