{"record":{"id":"56a2d65ed92e4155","repo":"stanfordnlp/CoreNLP","slug":"tokensregexnerannotator-error-invalid-group-in-li","errorCode":null,"errorMessage":"TokensRegexNERAnnotator ERROR: Invalid group in line  in regexner file : \"\"!","messagePattern":"TokensRegexNERAnnotator ERROR: Invalid group in line  in regexner file : \"\"!","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.java","lineNumber":800,"sourceCode":"      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\n      // Print some warnings about the type\n      for (int i = 0; i < types.length; i++) {\n        String type = types[i];\n        // TODO: Have option to allow commas in types\n        int commaPos = type.indexOf(',');\n        if (commaPos > 0) {\n          // Strip the \",\" and just take first type\n          String newType = type.substring(0, commaPos).trim();\n          logger.warn(annotatorName + \": Entry has multiple types for \" +\n                  annotationFieldnames[i] + \": \" + line + \".  Taking type to be \" + newType);\n          types[i] = newType;\n        }\n      }","sourceCodeStart":782,"sourceCodeEnd":818,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.java#L782-L818","documentation":"When the header defines a 'group' column, each line's group value is parsed with Integer.parseInt; a non-integer throws IllegalArgumentException showing line number, mapping file, and line text. The group selects which capture group of the pattern gets annotated and must be a plain integer.","triggerScenarios":"A group column containing text like 'first', 'g1', '2.0', or an empty/whitespace value; a shifted row putting another cell (e.g. a description) into the group column.","commonSituations":"Hand-written mapping files with descriptive group names; copy-paste rows where the group cell was lost; rows misaligned after header changes so a string column lands under 'group'.","solutions":["Replace the group value on the reported line with a plain integer (e.g. 0 or 1).","Remove the group column from header and rows if you want the default group 0.","Fix row alignment so each cell sits in its intended column.","Ensure the integer stays within the pattern's group count (see the related 'Invalid match group' runtime error)."],"exampleFix":"// before\n([ { word:/Dr\\./ } ]) ([ { ner:PERSON } ])\tTITLE\tperson\tfirst\n// after\n([ { word:/Dr\\./ } ]) ([ { ner:PERSON } ])\tTITLE\tperson\t2","handlingStrategy":"validation","validationCode":"for (String[] row : rows) {\n  String g = row[iGroup];\n  if (g != null && !g.trim().isEmpty()) Integer.parseInt(g.trim()); // throws NumberFormatException early with context\n}","typeGuard":null,"tryCatchPattern":"try { annotator = new TokensRegexNERAnnotator(name, props); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"Invalid group\")) { fixGroupOnLine(e.getMessage()); } else throw e; }","preventionTips":["Write group values as plain integers, never words or decimals","Omit the group column entirely when using the default group","Verify row alignment after header edits so string columns don't shift under 'group'"],"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"}