stanfordnlp/CoreNLP · error · RuntimeException
Character
Error message
Character
What it means
TraditionalSimplifiedCharacterMap.init() loads a traditional-to-simplified mapping file (cedict-derived) and fails if the same traditional character appears twice with a different simplified target, unless that character is in the hardcoded exception set. This guards against a corrupt or unexpectedly changed mapping file silently overwriting an entry.
Solutions
- Find the reported traditional character in the mapping file and remove or correct the conflicting duplicate line
- If the duplicate is legitimate, add the traditional character to hardcodedSet so it is allowed
- Diff your mapping file against the version shipped with the library to spot unintended additions
- Deduplicate the source cedict export before regenerating the mapping
Example fix
// before (mapping file) 龍 龙 龍 龙2 // after 龍 龙 // keep exactly one entry per traditional character
Defensive patterns
Strategy: validation
Validate before calling
Set<String> seen = new java.util.HashSet<>();
for (String line : java.nio.file.Files.readAllLines(mappingFile)) {
if (line.isBlank() || line.startsWith("#")) continue;
String t = line.substring(0, 1);
if (!seen.add(t)) throw new IllegalStateException("Duplicate traditional char in mapping file: " + t);
} Try / catch
try {
map = new TraditionalSimplifiedCharacterMap(resource);
} catch (RuntimeException e) {
log.error("Mapping file has duplicate/conflicting entry: " + e.getMessage());
throw new IOException("Corrupt traditional-simplified mapping", e);
} Prevention
- Deduplicate the source cedict export before regenerating the mapping file
- Diff custom mapping files against the shipped resource before deploying
- Keep hardcodedSet in sync when adding intentional exceptions
When it happens
Trigger: Loading a mapping resource where a line 'T<TAB>S' defines a traditional character that was already mapped to a different simplified character and is not whitelisted in hardcodedSet.
Common situations: Regenerating or hand-editing the cedict-derived mapping file and introducing duplicate keys; merging custom mappings with the shipped file; an upstream cedict data update conflicting with entries the library already hardcodes.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Attribute already defined:
- Attribute already defined
- Attribute match already defined:
- Attribute match already defined
- Duplicate attribute found in semgrex expression
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/25807ecb0e78db8b.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/trees/international/pennchinese/TraditionalSimplifiedCharacterMap.java:90
String simplified = transform[1];
map.put(traditional, simplified);
}
String line;
while ((line = reader.readLine()) != null) {
if (line.startsWith("#")) {
continue;
}
if (line.length() >= 3 &&
line.charAt(1) == ' ' && line.charAt(3) == ' ') {
// We're only interested in lines that represent a single character
String traditional = line.substring(0, 1);
String simplified = line.substring(2, 3);
// Fail on duplicates. Only a few come up in cedict, and
// those that do should already be accommodated
if (map.containsKey(traditional) && !hardcodedSet.contains(traditional) &&
!simplified.equals(map.get(traditional))) {
throw new RuntimeException("Character " + traditional + " mapped to " +
simplified + " already mapped to " +
map.get(traditional));
}
map.put(traditional, simplified);
}
}
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
public String apply(String input) {
StringBuilder translated = new StringBuilder();
for (int i = 0; i < input.length(); ++i) {
String c = input.substring(i, i + 1);
if (map.containsKey(c)) {
translated.append(map.get(c));
} else {View on GitHub (pinned to 1b7edd19c4)