{"record":{"id":"8eeb76b2720e8ade","repo":"stanfordnlp/CoreNLP","slug":"tokensregexnerannotator-error-invalid-weight-in-l","errorCode":null,"errorMessage":"TokensRegexNERAnnotator ERROR: Invalid weight in line  in regexner file : \"\"!","messagePattern":"TokensRegexNERAnnotator ERROR: Invalid weight in line  in regexner file : \"\"!","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.java","lineNumber":787,"sourceCode":"      } else {\n        overwritableTypes = Collections.emptySet();\n      }\n      if (iPriority >= 0 && split.length > iPriority) {\n        try {\n          priority = Double.parseDouble(split[iPriority].trim());\n        } catch (NumberFormatException e) {\n          throw new IllegalArgumentException(\"TokensRegexNERAnnotator \" + annotatorName\n              + \" ERROR: Invalid priority in line \" + lineCount\n              + \" in regexner file \" + mappingFilename + \": \\\"\" + line + \"\\\"!\", e);\n        }\n      }\n\n      double weight = 0.0;\n      if (iWeight >= 0 && split.length > iWeight) {\n        try {\n          weight = Double.parseDouble(split[iWeight].trim());\n        } catch (NumberFormatException e) {\n          throw new IllegalArgumentException(\"TokensRegexNERAnnotator \" + annotatorName\n              + \" ERROR: Invalid weight in line \" + lineCount\n              + \" in regexner file \" + mappingFilename + \": \\\"\" + line + \"\\\"!\", e);\n        }\n      }\n      int annotateGroup = 0;\n      // Get annotate group from input....\n      if (iGroup>= 0 && split.length > iGroup) {\n        // Which group to take (allow for context)\n        String context = split[iGroup].trim();\n        try {\n          annotateGroup = Integer.parseInt(context);\n        } catch (NumberFormatException e) {\n          throw new IllegalArgumentException(\"TokensRegexNERAnnotator \" + annotatorName\n              + \" ERROR: Invalid group in line \" + lineCount\n              + \" in regexner file \" + mappingFilename + \": \\\"\" + line + \"\\\"!\", e);\n        }\n      }\n","sourceCodeStart":769,"sourceCodeEnd":805,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.java#L769-L805","documentation":"When the header defines a 'weight' column, each line's weight is parsed with Double.parseDouble; a non-numeric value throws IllegalArgumentException showing line number, mapping file, and line text. Weights feed pattern scoring and must be valid doubles.","triggerScenarios":"A weight column holding non-numeric text such as 'strong', 'N/A', '1,5' (comma decimal), or a percent sign; a shifted row so a non-weight cell lands in the weight column.","commonSituations":"Hand-edited mapping files with descriptive weights; spreadsheet exports adding 'N/A' for missing values; column misalignment after inserting a column without updating all rows.","solutions":["Replace the weight on the reported line with a plain double such as 0.0 or 2.5.","Delete the weight column from both header and rows if weights aren't used.","Use '.' decimal separator and no units/symbols ('%', 'N/A').","Verify row alignment — ensure each row's column count matches the header so cells don't shift."],"exampleFix":"// before\n[ { word:/CFO/ } ]\tPERSON\tstrong\n// after\n[ { word:/CFO/ } ]\tPERSON\t2.0","handlingStrategy":"validation","validationCode":"for (String[] row : rows) {\n  String w = row[iWeight];\n  if (w != null && !w.trim().isEmpty()) Double.parseDouble(w.trim()); // fail early with row context\n}","typeGuard":null,"tryCatchPattern":"try { annotator = new TokensRegexNERAnnotator(name, props); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"Invalid weight\")) { fixWeightOnLine(e.getMessage()); } else throw e; }","preventionTips":["Use plain doubles for weight; avoid spreadsheet exports emitting 'N/A' or '%' symbols","Check row alignment after inserting or removing columns","Validate numeric columns in a CI linter"],"tags":["nlp","mapping-file","number-format","config-error"],"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-17T15:17:12.973Z"}