stanfordnlp/CoreNLP · error · java.lang.RuntimeException

More than one map in list while looking up word () in…

Error message

More than one map in list while looking up word () in phrase 

What it means

During lookup, when a trie node is a List, PhraseTable scans it expecting at most one sub-Map (the collapsed table for that prefix). Finding two Maps means the list was never converted to a map at MAX_LIST_SIZE as the invariant requires, so the structure is inconsistent. This is an internal-corruption error, not a user-input error.

Solutions

  1. Guard all writes with synchronization and rebuild the table from the original phrase list.
  2. Ensure phrases are added only via addPhrase/addPhrases, never by mutating internal structures.
  3. Update to a current CoreNLP version where list-to-map conversion bugs are fixed.
  4. Report to Stanford NLP with the word list if built single-threaded - it signals an internal bug.

Example fix

// before
synchronized(table) { table.addPhrase(a); }
// elsewhere, unsynchronized: table.addPhrase(b); // race corrupts list
// after
synchronized(table) { table.addPhrase(a); table.addPhrase(b); }
Defensive patterns

Strategy: validation

Validate before calling

// build fully under one lock before any lookup
synchronized (table) { for (String p : phrases) table.addPhrase(p); }

Try / catch

try { return table.lookup(wordList); } catch (RuntimeException e) { if (e.getMessage().startsWith("More than one map")) { return null; } throw e; }

Prevention

When it happens

Trigger: lookupIgnoringCase/lookup on a PhraseTable whose internal lookupList contains two Map entries - typically after concurrent addPhrase calls racing past the MAX_LIST_SIZE conversion step.

Common situations: Unsynchronized concurrent phrase insertion; custom code or reflection modifying the table's lists; running a table built by a different (buggy) version.

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/e22a160fb175f5d9. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/ling/tokensregex/PhraseTable.java:565

      } else if (node instanceof Map) {
        tree = (Map<String, Object>) node;
      } else if (node instanceof List) {
        // Search through list for matches to word (at this point, the table is small, so no Map)
        List lookupList = (List) node;
        int nMaps = 0;
        for (Object obj:lookupList) {
          if (obj instanceof Phrase) {
            // check rest of the phrase matches
            Phrase phrase = (Phrase) obj;
            int matchedTokenEnd = checkWordListMatch(
              phrase, wordList, 0, wordList.size(), i, true);

            if (matchedTokenEnd >= 0) {
              return phrase;
            }
          } else if (obj instanceof Map) {
            if (nMaps == 1) {
              throw new RuntimeException("More than one map in list while looking up word "
                      + i + "(" + word + ") in phrase " + wordList.toString());
            }
            tree = (Map<String, Object>) obj;
            nMaps++;
          } else  {
            throw new RuntimeException("Unexpected class in list " + obj.getClass() + " while looking up word "
                    + i + "(" + word + ") in phrase " + wordList.toString());
          }
        }
        if (nMaps == 0) {
          return null;
        }
      } else {
        throw new RuntimeException("Unexpected class in list " + node.getClass() + " while looking up word "
                + i + "(" + word + ") in phrase " + wordList.toString());
      }
    }
    Phrase phrase = (Phrase) tree.get(PHRASE_END);

View on GitHub (pinned to 1b7edd19c4)