{"record":{"id":"10953d7cee2c659d","repo":"stanfordnlp/CoreNLP","slug":"ptblexer-invalid-option-value-in-constructor","errorCode":null,"errorMessage":"PTBLexer: Invalid option value in constructor: ","messagePattern":"PTBLexer: Invalid option value in constructor: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/process/PTBLexer.flex","lineNumber":241,"sourceCode":"                untokenizable = UntokenizableOptions.NONE_DELETE;\n                break;\n              case \"firstDelete\":\n                untokenizable = UntokenizableOptions.FIRST_DELETE;\n                break;\n              case \"allDelete\":\n                untokenizable = UntokenizableOptions.ALL_DELETE;\n                break;\n              case \"noneKeep\":\n                untokenizable = UntokenizableOptions.NONE_KEEP;\n                break;\n              case \"firstKeep\":\n                untokenizable = UntokenizableOptions.FIRST_KEEP;\n                break;\n              case \"allKeep\":\n                untokenizable = UntokenizableOptions.ALL_KEEP;\n                break;\n              default:\n                throw new IllegalArgumentException(\"PTBLexer: Invalid option value in constructor: \" + key + \": \" + value);\n            }\n          } else if (\"strictTreebank3\".equals(key)) {\n            strictFraction = val;\n            strictAcronym = val;\n          } else if (\"strictFraction\".equals(key)) {\n            strictFraction = val;\n          } else if (\"strictAcronym\".equals(key)) {\n            strictAcronym = val;\n          } else {\n            throw new IllegalArgumentException(\"PTBLexer: Invalid options key in constructor: \" + key);\n          }\n        }\n        if (invertible) {\n          if ( ! (tf instanceof CoreLabelTokenFactory)) {\n            throw new IllegalArgumentException(\"PTBLexer: the invertible option requires a CoreLabelTokenFactory\");\n          }\n          prevWord = (CoreLabel) tf.makeToken(\"\", 0, 0);\n          prevWordAfter = new StringBuilder();","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/process/PTBLexer.flex#L223-L259","documentation":"PTBLexer's constructor option parser throws this when an option key/value pair receives a value outside the allowed set — notably for 'untokenizable', whose value must match one of the UntokenizableOptions cases (e.g. noneDelete, delete, firstKeep, allKeep). Any unrecognized value reaches the default branch and throws.","triggerScenarios":"Passing an options string like 'untokenizable=keepAll' or any 'key=value' where value fails the accepted switch cases for keys validated via a switch (untokenizable, etc.).","commonSituations":"Typos such as 'untokenizable=allkeep' vs 'allKeep' are tolerated by case but misspellings like 'keepall' are not; copying options from another tokenizer; assuming arbitrary strings are accepted.","solutions":["Use an accepted UntokenizableOptions string: noneDelete, firstKeep, allKeep (or the other documented cases)","Inspect the switch in PTBLexer.flex to confirm the exact accepted values for the offending key","Fix the option spelling/casing in the tokenizer options string"],"exampleFix":"// before\nnew PTBTokenizer<>(reader, new CoreLabelTokenFactory(), \"untokenizable=keepAll\");\n// after\nnew PTBTokenizer<>(reader, new CoreLabelTokenFactory(), \"untokenizable=allKeep\");","handlingStrategy":"validation","validationCode":"List<String> ok = Arrays.asList(\"noneDelete\",\"firstDelete\",\"firstKeep\",\"allKeep\");\nif (key.equals(\"untokenizable\") && !ok.contains(value)) throw new IllegalArgumentException(\"invalid untokenizable: \" + value);","typeGuard":null,"tryCatchPattern":"try {\n  lexer = new PTBLexer(reader, options);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Invalid option value\")) { /* correct the value or fall back to \"untokenizable=noneDelete\" */ }\n  throw e;\n}","preventionTips":["Use UntokenizableOptions enum names as the single source of truth","Validate whole option strings in a config-loading step","Add a regression test per option value you rely on"],"tags":["tokenization","options","illegal-argument"],"backgroundTag":"invalid-enum-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"}