{"record":{"id":"3dbdd3d2e700497a","repo":"stanfordnlp/CoreNLP","slug":"unrecognized-format-specification-in-format","errorCode":null,"errorMessage":"Unrecognized format specification in ${format}","messagePattern":"Unrecognized format specification in (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/classify/ColumnDataClassifier.java","lineNumber":816,"sourceCode":"        if (ch2 >= '0' && ch2 <= '9') {\n          int field = ch2 - '0';\n          if (field < fields.length) {\n            out.append(fields[field]);\n          } else {\n            throw new IllegalArgumentException(\"Not enough columns for format \" + format);\n          }\n        } else if (ch2 == 'c') {\n          if (answer != null) {\n            out.append(answer);\n          } else if (globalFlags.goldAnswerColumn < fields.length) {\n            out.append(fields[globalFlags.goldAnswerColumn]);\n          } else {\n            out.append(\"Class\");\n          }\n        } else if (ch2 == 'n') {\n          out.append('\\n');\n        } else {\n          throw new IllegalArgumentException(\"Unrecognized format specification in \" + format);\n        }\n        i++; // have also dealt with next character giving format\n      } else {\n        out.append(ch);\n      }\n    }\n    return out.toString();\n  }\n\n\n  /**\n   * Extracts all the features from a certain input datum.\n   *\n   * @param strs The data String[] to extract features from\n   * @return The constructed Datum\n   */\n  private Datum<String,String> makeDatum(String[] strs) {\n    String goldAnswer = globalFlags.goldAnswerColumn < strs.length ? strs[globalFlags.goldAnswerColumn]: \"\";","sourceCodeStart":798,"sourceCodeEnd":834,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/classify/ColumnDataClassifier.java#L798-L834","documentation":"formatCsv parses the -csvFormat string character by character; after '$' only digits, 'c' (class/gold answer), or 'n' (newline) are valid. Any other character following '$' throws IllegalArgumentException naming the full format string, protecting users from silently malformed output templates.","triggerScenarios":"A csvFormat containing an unsupported escape after '$', e.g. \"$x\", \"$t\", \"$ \" — passed via testExamples/testExample properties.","commonSituations":"Typo in format string; assuming tab can be written as '$t' instead of a literal tab or '\\t'; copying formats between tools with different specifiers.","solutions":["Replace the invalid specifier with a digit index, '$c' (gold answer class), or '$n' (newline)","Use a literal tab character (or real \\t in the property) instead of '$t'","Print the format string from properties to spot invisible/typo characters"],"exampleFix":"// before\nprops.setProperty(\"csvFormat\", \"$0\\t$t\\n\");\n// after\nprops.setProperty(\"csvFormat\", \"$0\\t$1\\t$c$n\");","handlingStrategy":"validation","validationCode":"if (!csvFormat.matches(\"(\\$[0-9cn]|[^$])*(\\$[0-9cn]|[^$])*\")) { /* validate: every $ is followed by digit, c, or n */ for (int i=0;i<csvFormat.length()-1;i++) if (csvFormat.charAt(i)=='$' && !\"cn\".contains(String.valueOf(csvFormat.charAt(i+1))) && !Character.isDigit(csvFormat.charAt(i+1))) throw new IllegalStateException(\"Bad specifier at \" + i); }","typeGuard":"null","tryCatchPattern":"try { testExamples(...); } catch (IllegalArgumentException e) { log.error(\"Invalid csvFormat string: \" + e.getMessage()); }","preventionTips":["Use only $digit, $c, or $n specifiers in csvFormat","Write literal tabs/newlines instead of inventing specifiers like $t","Unit-test your format string on one sample line before batch runs"],"tags":["java","column-data-classifier","format-specification"],"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"}