{"record":{"id":"ec2a2edde0fc56f8","repo":"stanfordnlp/CoreNLP","slug":"expected-lines-of-the-format-original-tab-replac","errorCode":null,"errorMessage":"Expected lines of the format original (tab) replacement.  Line number  does not match.","messagePattern":"Expected lines of the format original \\(tab\\) replacement\\.  Line number  does not match\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/tregex/Macros.java","lineNumber":50,"sourceCode":"    } catch (IOException e) {\n      throw new RuntimeIOException(e);\n    }\n  }\n\n  public static List<Pair<String, String>> readMacros(BufferedReader bin) {\n    try {\n      List<Pair<String, String>> macros = new ArrayList<>();\n      String line;\n      int lineNumber = 0;\n      while ((line = bin.readLine()) != null) {\n        ++lineNumber;\n        String trimmed = line.trim();\n        if (trimmed.equals(\"\") || trimmed.charAt(0) == '#') {\n          continue;\n        }\n        String[] pieces = line.split(\"\\t\", 2);\n        if (pieces.length < 2) {\n          throw new IllegalArgumentException(\"Expected lines of the format \" +\n                                             \"original (tab) replacement.  \" +\n                                             \"Line number \" + lineNumber +\n                                             \" does not match.\");\n        }\n        macros.add(new Pair<>(pieces[0], pieces[1]));\n      }\n      return macros;\n    } catch (IOException e) {\n      throw new RuntimeIOException(e);\n    }\n  }\n\n  public static void addAllMacros(TregexPatternCompiler compiler,\n                                  String filename, String encoding) {\n    if (filename == null || filename.equals(\"\")) {\n      return;\n    }\n    for (Pair<String, String> macro : readMacros(filename, encoding)) {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/tregex/Macros.java#L32-L68","documentation":"Macros.readMacros() loads tregex macro files where each non-comment, non-blank line must be 'original<TAB>replacement'. A line without a tab separator cannot be split into two pieces and triggers IllegalArgumentException with the offending line number.","triggerScenarios":"A macro file line contains an identifier with no tab (spaces used instead of tab, or replacement missing entirely); reading a file whose lines split(\"\\t\", 2) yields fewer than 2 elements.","commonSituations":"Hand-editing macro files with editors that replace tabs with spaces; copying macro definitions from markdown/HTML where tabs became spaces or got lost; truncated files losing the replacement column.","solutions":["Fix the line number reported by the error so original and replacement are separated by an actual TAB character","Replace space separators with tabs (editors: enable 'expand tabs off' or use sed -i 's/ /\\t/')","Ensure every macro line has both the original expression and its replacement","Strip HTML/markdown artifacts when copying macro files from docs"],"exampleFix":"// before (macro file, space-separated)\nNP noun-phrase\n// after (tab-separated)\nNP\tnoun-phrase","handlingStrategy":"validation","validationCode":"int ln = 0;\nfor (String line : Files.readAllLines(macroFile)) {\n  ln++;\n  String t = line.trim();\n  if (t.isEmpty() || t.startsWith(\"#\")) continue;\n  if (!line.contains(\"\\t\")) throw new IllegalArgumentException(\"Macro line \" + ln + \" lacks a TAB separator\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  Macros.readMacros(reader, macros);\n} catch (IllegalArgumentException e) {\n  System.err.println(e.getMessage()); // names the bad line number\n  // fix the macro file (use a real TAB), then reload\n}","preventionTips":["Configure editors to insert real tabs in macro files","Validate macro files with a pre-check before loading","Copy macro files as raw text, not from rendered markdown/HTML"],"tags":["java","file-parsing","format","tregex"],"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"}