stanfordnlp/CoreNLP · error · Error
Attribute already defined
Error message
Attribute already defined: ${attr.image} What it means
Similar to the attribute-match check, this parser production parses simple attribute assignments (no match-value concatenation) and throws 'Attribute already defined: <attr>' when the same attribute key is assigned twice in one attribute block. The map check at line 1919 rejects the second assignment.
Solutions
- Delete the duplicate attribute assignment or keep only the intended value.
- If multiple values are needed, use a regex or disjunction in one attribute value.
- Lint rule files for duplicate keys before loading them into the annotator.
- Fix the generating code if rules are produced programmatically.
Example fix
// before
String node = "{ word:\"foo\" word:\"bar\" }";
// after
String node = "{ word:/foo|bar/ }"; Defensive patterns
Strategy: validation
Validate before calling
java.util.Set<String> seen = new java.util.HashSet<>();
for (String line : attributeLines) {
String key = line.split(":", 2)[0].trim();
if (!seen.add(key)) throw new IllegalStateException("Attribute assigned twice: " + key);
} Try / catch
try {
attrs = parser.parseAttributeList(text);
} catch (Error e) {
if (e.getMessage() != null && e.getMessage().startsWith("Attribute already defined")) {
throw new IllegalArgumentException("Duplicate attribute assignment: " + e.getMessage(), e);
}
throw e;
} Prevention
- Keep one assignment per attribute key per node.
- Merge duplicate assignments into a single value or disjunction.
- If rules are generated, assert uniqueness of keys before emission.
When it happens
Trigger: Parsing an attribute list such as '{ word:"foo" word:"bar" }' where an attribute key is set more than once in the same specification.
Common situations: Generated or machine-merged TokensRegex rules emitting duplicate attribute assignments; developers duplicating a line when editing rules by hand.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- Attribute match already defined
- Field already defined:
- Attribute match already defined:
- Attribute already defined:
- Unknown sequence pattern variable
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/050467552cc12f2d.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/ling/tokensregex/parser/TokenSequenceParser.java:1919
case STR:{
value = RelaxedStringToken();
break;
}
case NONNEGINT:
case INT:
case REAL:{
value = NumberToken();
break;
}
default:
jj_la1[65] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
if (value != null) { str = value.image; }
if (attr != null && str != null) {
if (attributes.containsKey(attr.image)) {
{if (true) throw new Error("Attribute already defined: " + attr.image);}
}
attributes.put(attr.image, str);
}
{if ("" != null) return attributes;}
throw new Error("Missing return statement in function");
}
final public Token NumberToken() throws ParseException {Token value = null;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case NONNEGINT:{
value = jj_consume_token(NONNEGINT);
break;
}
case INT:{
value = jj_consume_token(INT);
break;
}
case REAL:{View on GitHub (pinned to 1b7edd19c4)