{"record":{"id":"39f251bc3fe90e6d","repo":"stanfordnlp/CoreNLP","slug":"tokensregexnerannotator-error-incorrectly-specifi","errorCode":null,"errorMessage":"TokensRegexNERAnnotator ERROR: Incorrectly specified options for mapping file ","messagePattern":"TokensRegexNERAnnotator ERROR: Incorrectly specified options for mapping file ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.java","lineNumber":896,"sourceCode":"    } else {\n      //Semicolons separate the files\n      return SEMICOLON_DELIMITERS_PATTERN.split(mappingFiles);\n    }\n  }\n  private static String[] processPerFileOptions(String annotatorName, String[] mappings, List<Boolean> ignoreCaseList, List<Pattern> validPosPatternList, List<String[]> headerList, boolean ignoreCase, Pattern validPosPattern, String[] headerFields, String[] annotationFieldnames, List<Class> annotationFields) {\n    int numMappingFiles = mappings.length;\n    for (int index = 0; index < numMappingFiles; index++) {\n      boolean ignoreCaseSet = false;\n      boolean validPosPatternSet = false;\n      boolean headerSet = false;\n      String[] allOptions = COMMA_DELIMITERS_PATTERN.split(mappings[index].trim());\n      int numOptions = allOptions.length;\n      String filePath = allOptions[allOptions.length - 1];\n      if (numOptions > 1) { // there are some per file options here\n        for (int i = 0; i < numOptions-1; i++) {\n          String[] optionAndValue = EQUALS_DELIMITERS_PATTERN.split(allOptions[i].trim());\n          if (optionAndValue.length != 2) {\n            throw new IllegalArgumentException(\"TokensRegexNERAnnotator \" + annotatorName\n                    + \" ERROR: Incorrectly specified options for mapping file \" + mappings[index].trim());\n          } else {\n            switch (optionAndValue[0].trim().toLowerCase()) {\n              case \"ignorecase\":\n                ignoreCaseList.add(Boolean.parseBoolean(optionAndValue[1].trim()));\n                ignoreCaseSet = true;\n                break;\n              case \"validpospattern\":\n                String validPosRegex = optionAndValue[1].trim();\n                if ( ! StringUtils.isNullOrEmpty(validPosRegex)) {\n                  validPosPatternList.add(Pattern.compile(validPosRegex));\n                } else {\n                  validPosPatternList.add(validPosPattern);\n                }\n                validPosPatternSet = true;\n                break;\n              case \"header\":\n                String header = optionAndValue[1].trim();","sourceCodeStart":878,"sourceCodeEnd":914,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.java#L878-L914","documentation":"TokensRegexNERAnnotator parses each mapping-file entry as an optional list of key=value options followed by the file path. When the path component count (numOptions) is greater than 1, every option before the last must split on '=' into exactly two parts; if an option lacks '=' (or contains extra '=' splitting behavior producing != 2 parts), the annotator throws this IllegalArgumentException at construction time.","triggerScenarios":"Setting the property tokensregexner.mapping.<annotatorName> (or 'mapping') with a comma/semicolon separated list where a per-file option is malformed, e.g. 'ignoreCase/mapping.ser.gz' (missing '='), 'ignoreCase=true,extra mapping.ser.gz' (empty option string), or 'a=b=c,file' where the delimiter split yields more or fewer than 2 parts.","commonSituations":"Typos like 'ignorecase tru' vs 'ignorecase=true', copying options from docs with wrong separators, trailing commas producing empty option segments, or mixing up the order so a path lands in the options slot.","solutions":["Ensure every per-mapping option is written exactly as key=value, e.g. 'ignorecase=true' before the file path","Check for stray/empty segments between delimiters (double commas or trailing commas) in the mapping property","Confirm the mapping file path is the LAST item in the list and contains no option-like '=' handling issues","Quote the whole property value in your properties file/shell so delimiters are not mangled"],"exampleFix":"// before\nProperties props = new Properties();\nprops.setProperty(\"tokensregexner.mapping\", \"ignorecase true,my_rules.tsv\");\n// after\nprops.setProperty(\"tokensregexner.mapping\", \"ignorecase=true,my_rules.tsv\");","handlingStrategy":"validation","validationCode":"String mapping = props.getProperty(\"tokensregexner.mapping\");\nif (mapping != null) {\n  for (String entry : mapping.split(\",\")) {\n    String trimmed = entry.trim();\n    if (trimmed.contains(\"=\") && trimmed.split(\"=\").length != 2)\n      throw new IllegalArgumentException(\"Malformed option: \" + trimmed);\n    if (!trimmed.equals(\"\") && !trimmed.contains(\"=\") && !new java.io.File(trimmed).exists())\n      // could still be an option with missing '='\n      if (!trimmed.matches(\".*\\\\.(gz|txt|tsv|ser)$\"))\n        throw new IllegalArgumentException(\"Option missing '=': \" + trimmed);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  pipeline.annotate(doc);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Incorrectly specified options\")) {\n    log.error(\"Fix tokensregexner.mapping: every per-file option must be key=value\");\n  }\n  throw e;\n}","preventionTips":["Always write mapping options as key=value pairs immediately before the file path","Keep the file path as the last element of the mapping list","Validate the mapping property string in unit tests before building the pipeline","Avoid trailing/double delimiters in the property value"],"tags":["configuration","parsing","tokensregexner"],"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"}