{"record":{"id":"d5c6ab10782ca754","repo":"stanfordnlp/CoreNLP","slug":"cannot-have-these-two-ordering-constraints-last","errorCode":null,"errorMessage":"Cannot have these two ordering constraints: ${lastSieveConstraint},${ordering}","messagePattern":"Cannot have these two ordering constraints: (.+?),(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/dcoref/SieveCoreferenceSystem.java","lineNumber":259,"sourceCode":"    }\n    optimizeSubScoreType = CorefScorer.SubScoreType.valueOf(parts[1]);\n\n    if (optimizeSieves) {\n      String keepSieveOrder = props.getProperty(Constants.OPTIMIZE_SIEVES_KEEP_ORDER_PROP);\n      if (keepSieveOrder != null) {\n        String[] orderings = keepSieveOrder.split(\"\\\\s*,\\\\s*\");\n        sievesKeepOrder = new ArrayList<>();\n        String firstSieveConstraint = null;\n        String lastSieveConstraint = null;\n        for (String ordering:orderings) {\n          // Convert ordering constraints from string\n          Pair<Integer,Integer> p = fromSieveOrderConstraintString(ordering, sieveClassNames);\n          // Do initial check of sieves order, can only have one where the first is ANY (< 0), and one where second is ANY (< 0)\n          if (p.first() < 0 && p.second() < 0) {\n            throw new IllegalArgumentException(\"Invalid ordering constraint: \" + ordering);\n          } else if (p.first() < 0) {\n            if (lastSieveConstraint != null) {\n              throw new IllegalArgumentException(\"Cannot have these two ordering constraints: \" + lastSieveConstraint + \",\" + ordering);\n            }\n            lastSieveConstraint = ordering;\n          } else if (p.second() < 0) {\n            if (firstSieveConstraint != null) {\n              throw new IllegalArgumentException(\"Cannot have these two ordering constraints: \" + firstSieveConstraint + \",\" + ordering);\n            }\n            firstSieveConstraint = ordering;\n          }\n          sievesKeepOrder.add(p);\n        }\n      }\n    }\n\n    if(doScore){\n      initScorers();\n    }\n\n    //","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/dcoref/SieveCoreferenceSystem.java#L241-L277","documentation":"Among the sieve ordering constraints, at most one may have the wildcard '*' as its FIRST element (an 'anything-before-this' constraint). If a second such constraint appears, the constructor throws an IllegalArgumentException naming the two conflicting constraints, because no total sieve order can be checked/optimized against two simultaneous ANY-first constraints.","triggerScenarios":"Configuring the sieve-ordering property with two constraints that both start with '*', e.g. '*<A' followed by '*<B'; detected when the loop encounters p.first()<0 while lastSieveConstraint is already set.","commonSituations":"Accumulating leftover wildcard constraints in a coref tuning properties file after edits; misunderstanding that only one '*<' constraint is allowed; automated constraint generation that doesn't dedupe ANY-first entries.","solutions":["Keep only one constraint of the form '*<SieveName' in the ordering property","Delete or rewrite the second ANY-first constraint to name an explicit sieve on the left","Check the lastSieveConstraint conflict message in the exception — it tells you exactly which two constraints collide","Validate the full constraint list (one ANY-first, one ANY-second max) before running the system"],"exampleFix":"// before\ndcoref.optimize.sievesOrder = *<ExactStringMatch, *<ProperNounMatch\n// after\ndcoref.optimize.sievesOrder = *<ExactStringMatch, ProperNounMatch<ExactStringMatch","handlingStrategy":"validation","validationCode":"String[] orderings = props.getProperty(\"dcoref.optimize.sievesOrder\",\"\").split(\",\");\nint anyFirst = 0;\nfor (String o : orderings) {\n  String[] sides = o.split(\"<\");\n  if (sides.length == 2 && sides[0].trim().equals(\"*\") && ++anyFirst > 1)\n    throw new IllegalArgumentException(\"Only one '*<X' allowed: \" + o);\n}","typeGuard":null,"tryCatchPattern":"try {\n  new SieveCoreferenceSystem(props);\n} catch (IllegalArgumentException e) {\n  logger.severe(\"Constraint conflict: \" + e.getMessage());\n  // parse message, drop the duplicated ANY-first constraint, retry\n}","preventionTips":["Enforce 'at most one *<X constraint' as an invariant in any config generator","Keep ordering constraints in a reviewed, versioned config file","Test new constraint sets against a tiny corpus before long optimization runs"],"tags":["corenlp","coreference","configuration","ordering-constraints"],"backgroundTag":"conflicting-config-options","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}