{"record":{"id":"73fbdc0730e82579","repo":"stanfordnlp/CoreNLP","slug":"arc-input-is-in-unexpected-format","errorCode":null,"errorMessage":"Arc input is in unexpected format: ","messagePattern":"Arc input is in unexpected format: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/GrammarCompactor.java","lineNumber":329,"sourceCode":"          UnaryRule ur = new UnaryRule(newStateIndex.addToIndex(target), newStateIndex.addToIndex(inputString), smartNegate(output));\n          unaryRules.add(ur);\n        } else if (inputString.equals(END) || inputString.equals(EPSILON)) {\n          // make a UnaryRule\n          UnaryRule ur = new UnaryRule(newStateIndex.addToIndex(target), newStateIndex.addToIndex(source), smartNegate(output));\n          unaryRules.add(ur);\n        } else {\n          // make a BinaryRule\n          // figure out whether the input was generated on the left or right\n          int length = inputString.length();\n          char leftOrRight = inputString.charAt(length - 1);\n          inputString = inputString.substring(0, length - 1);\n          BinaryRule br;\n          if (leftOrRight == '<' || leftOrRight == '[') {\n            br = new BinaryRule(newStateIndex.addToIndex(target), newStateIndex.addToIndex(inputString), newStateIndex.addToIndex(source), smartNegate(output));\n          } else if (leftOrRight == '>' || leftOrRight == ']') {\n            br = new BinaryRule(newStateIndex.addToIndex(target), newStateIndex.addToIndex(source), newStateIndex.addToIndex(inputString), smartNegate(output));\n          } else {\n            throw new RuntimeException(\"Arc input is in unexpected format: \" + arc);\n          }\n          binaryRules.add(br);\n        }\n      }\n    }\n    // by now, the unaryRules and binaryRules Sets have old untouched and new rules with scores\n    ClassicCounter<String> symbolCounter = new ClassicCounter<>();\n    if (outputType == RAW_COUNTS) {\n      // now we take the sets of rules and turn them into grammars\n      // the scores of the rules we are given are actually counts\n      // so we count parent symbol occurrences\n      for (UnaryRule rule : unaryRules) {\n        symbolCounter.incrementCount(newStateIndex.get(rule.parent), rule.score);\n      }\n      for (BinaryRule rule : binaryRules) {\n        symbolCounter.incrementCount(newStateIndex.get(rule.parent), rule.score);\n      }\n    }","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/GrammarCompactor.java#L311-L347","documentation":"When converting compacted transducer graphs back into grammar rules, binary-rule arc inputs encode direction with '<'/'[' (left) or '>'/']' (right). If an arc's input string has neither marker, its orientation cannot be determined, so convertGraphsToGrammar throws with the offending arc.","triggerScenarios":"Compacting a grammar whose transducer graph contains arcs not created by the standard binary-rule encoding — e.g. graphs loaded from custom code or corrupted graph data.","commonSituations":"Using saveGraphs/graph-restore features across versions where arc input conventions changed, or feeding custom TransducerGraphs into the compactor.","solutions":["Regenerate the graphs through the standard compaction path so arc inputs carry the '<'/'>' (or '['/']') marker.","Check for version mismatch between the code that wrote the graphs and the code reading them.","Disable grammar compaction for grammars produced outside the standard pipeline."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for (Arc<String> arc : graph.getArcs()) {\n    String in = arc.getInput();\n    if (!(in.contains(\"<\") || in.contains(\">\") || in.contains(\"[\") || in.contains(\"]\")))\n        throw new IllegalArgumentException(\"Bad arc input: \" + arc);\n}","typeGuard":null,"tryCatchPattern":"try { grammar = compactor.compact(graphs); } catch (RuntimeException e) { log.error(e.getMessage()); throw e; }","preventionTips":["Build transducer graphs only via the standard compaction code path","Avoid mixing graph files across parser versions"],"tags":["grammar-compaction","arc-format","parser","malformed-input"],"backgroundTag":"invalid-argument-format","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"}