{"record":{"id":"74c08305222126dd","repo":"stanfordnlp/CoreNLP","slug":"invalid-value-for-distancebin","errorCode":null,"errorMessage":"Invalid value for -distanceBin: ","messagePattern":"Invalid value for -distanceBin: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/Options.java","lineNumber":313,"sourceCode":"      if (order >= 0) {\n        trainOptions.markovOrder = order;\n        trainOptions.markovFactor = true;\n      } else {\n        trainOptions.markovFactor = false;\n      }\n      i += 2;\n    } else if (args[i].equalsIgnoreCase(\"-distanceBins\") && (i + 1 < args.length)) {\n      int numBins = Integer.parseInt(args[i + 1]);\n      if (numBins <= 1) {\n        distance = false;\n      } else if (numBins == 4) {\n        distance = true;\n        coarseDistance = true;\n      } else if (numBins == 5) {\n        distance = true;\n        coarseDistance = false;\n      } else {\n        throw new IllegalArgumentException(\"Invalid value for -distanceBin: \" + args[i+1]);\n      }\n      i += 2;\n    } else if (args[i].equalsIgnoreCase(\"-noStop\")) {\n      genStop = false;\n      i++;\n    } else if (args[i].equalsIgnoreCase(\"-nonDirectional\")) {\n      directional = false;\n      i++;\n    } else if (args[i].equalsIgnoreCase(\"-depWeight\") && (i + 1 < args.length)) {\n      testOptions.depWeight = Double.parseDouble(args[i + 1]);\n      i += 2;\n    } else if (args[i].equalsIgnoreCase(\"-printPCFGkBest\") && (i + 1 < args.length)) {\n      testOptions.printPCFGkBest = Integer.parseInt(args[i + 1]);\n      i += 2;\n    } else if (args[i].equalsIgnoreCase(\"-evalPCFGkBest\") && (i + 1 < args.length)) {\n      testOptions.evalPCFGkBest = Integer.parseInt(args[i + 1]);\n      i += 2;\n    } else if (args[i].equalsIgnoreCase(\"-printFactoredKGood\") && (i + 1 < args.length)) {","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/Options.java#L295-L331","documentation":"Options.setOptionFlag validates the -distanceBin argument value: only specific bin counts are supported (distance/coarseDistance combinations, e.g., numBins of 4 or 5). Any other value for -distanceBin makes the parser throw IllegalArgumentException('Invalid value for -distanceBin: ...').","triggerScenarios":"Supplying '-distanceBin' on the command line (or via setOptions) with a numeric value that is not one of the supported bin counts (e.g., -distanceBin 3 or -distanceBin 6).","commonSituations":"Copying training options from an old config that used a different number of distance bins, or guessing the allowed values without checking the source.","solutions":["Use one of the supported values for -distanceBin (check the numBins branches in setOptionFlag; 4 or 5).","Remove the -distanceBin flag to use the default distance binning.","Update your training script/config to match the option values supported by your parser version."],"exampleFix":"// before\njava -cp stanford-parser.jar ... -distanceBin 3 ...\n// after\njava -cp stanford-parser.jar ... -distanceBin 5 ...","handlingStrategy":"validation","validationCode":"if (flag.equals(\"-distanceBin\")) {\n  int v = Integer.parseInt(value);\n  if (v != 4 && v != 5) throw new IllegalArgumentException(\"distanceBin must be 4 or 5, got \" + v);\n}","typeGuard":null,"tryCatchPattern":"try {\n  options.setOptions(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Invalid value for -distanceBin\")) {\n    args[argsIdx+1] = \"5\"; // retry with supported value\n  }\n}","preventionTips":["Check the setOptionFlag source for allowed numBins values before using -distanceBin.","Omit the flag to get defaults unless binning behavior is required.","Version-pin training configs to the parser release they were written for."],"tags":["cli","parser-options","illegal-argument"],"backgroundTag":"invalid-flag-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}