{"record":{"id":"1168351d56bbff4b","repo":"stanfordnlp/CoreNLP","slug":"ptblexer-invalid-options-key-in-constructor","errorCode":null,"errorMessage":"PTBLexer: Invalid options key in constructor: ","messagePattern":"PTBLexer: Invalid options key in constructor: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/process/PTBLexer.flex","lineNumber":251,"sourceCode":"                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();\n        }\n        if (tokenizePerLine) {\n          yybegin(YyTokenizePerLine);\n        } else {\n          yybegin(YyNotTokenizePerLine);\n        }\n      }\n\n\n      /** Turn on to find out how things were tokenized. */","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/process/PTBLexer.flex#L233-L269","documentation":"PTBLexer's options-map constructor validates each key against a known set (normalize, ellipses, dashes, escapeForwardSlashAsterisk, untokenizable, strictTreebank3, strictFraction, strictAcronym, invertible, tokenizePerLine, etc.). An unknown key falls into the final else and throws IllegalArgumentException.","triggerScenarios":"Calling PTBLexer(Reader, Map<String,String>) or PTBTokenizer with a Map containing a misspelled or unsupported key, e.g. 'tokenizeNLs' vs 'tokenizePerLine', or a stale key from an older CoreNLP version.","commonSituations":"Typos in option keys; options copied from other tokenizers (e.g. WhitespaceTokenizer options); keys removed/renamed across CoreNLP releases.","solutions":["Check the key against the if/else chain in PTBLexer.flex and correct the spelling","Remove the unsupported key from the options map","Consult the PTBTokenizer javadoc for the current list of valid option keys"],"exampleFix":"// before\noptions.put(\"americanise\", \"true\");\n// after\noptions.put(\"normalizeParentheses\", \"true\");","handlingStrategy":"validation","validationCode":"Set<String> known = Set.of(\"normalize\",\"normalizeParentheses\",\"normalizeOtherBrackets\",\"ellipses\",\"dashes\",\"escapeForwardSlashAsterisk\",\"untokenizable\",\"strictTreebank3\",\"strictFraction\",\"strictAcronym\",\"invertible\",\"tokenizePerLine\",\"tokenizeNLs\");\nfor (String k : options.keySet()) if (!known.contains(k)) throw new IllegalArgumentException(\"unknown PTBTokenizer option: \" + k);","typeGuard":null,"tryCatchPattern":"try {\n  lexer = new PTBLexer(reader, options);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Invalid options key\")) { /* log the bad key and drop it, or fail config load */ }\n  throw e;\n}","preventionTips":["Copy option keys from the PTBTokenizer javadoc, not memory","Check keys against the current CoreNLP version when upgrading","Centralize option-key names in a shared constants class"],"tags":["tokenization","options","illegal-argument"],"backgroundTag":"invalid-config-key","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"}