{"record":{"id":"18cff00cb87632cc","repo":"stanfordnlp/CoreNLP","slug":"need-to-give-a-pattern-location-with-patterns","errorCode":null,"errorMessage":"Need to give a pattern location with -patterns","messagePattern":"Need to give a pattern location with -patterns","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java","lineNumber":1160,"sourceCode":"  /**\n   * Performs a simple test and print of a given file.\n   * Usage Ssurgeon [-info infoFile] -patterns patternDir [-type interactive|testinfo]\n   */\n  public static void main(String[] args) {\n    for (int argIndex = 0; argIndex < args.length; ++argIndex) {\n      if (args[argIndex].equalsIgnoreCase(\"-info\")) {\n        argsBox.info = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-patterns\")) {\n        argsBox.patternDirStr = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-type\")) {\n        argsBox.type = RUNTYPE.valueOf(args[argIndex + 1]);\n        argIndex += 2;\n      }\n    }\n    if (argsBox.patternDirStr == null) {\n      throw new IllegalArgumentException(\"Need to give a pattern location with -patterns\");\n    }\n    argsBox.init();\n\n    System.out.println(argsBox);\n    try {\n      if (argsBox.type == RUNTYPE.interactive) {\n        Ssurgeon.inst().testRead(argsBox.patternDir);\n      }\n    } catch (Exception e) {\n      log.error(e);\n    }\n  }\n\n}\n","sourceCodeStart":1142,"sourceCodeEnd":1175,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java#L1142-L1175","documentation":"Ssurgeon's main() command-line driver requires the -patterns argument pointing at the Ssurgeon rules location. When argument parsing finishes without a pattern directory/file set, it throws IllegalArgumentException before any processing begins.","triggerScenarios":"Running java edu.stanford.nlp.semgraph.semgrex.ssurgeon.Ssurgeon without -patterns, or misspelling the flag so it is not consumed.","commonSituations":"CLI invocations copied from docs that omitted -patterns; shell scripts where the variable holding the path is empty; confusing -patterns with other flag names.","solutions":["Add -patterns <path> (rules file or directory) to the command line","Check the flag spelling and that the variable holding the path is non-empty in your script","Run without args / consult the usage message to see required flags"],"exampleFix":"// before\njava Ssurgeon -treebank trees/ -type interactive\n// after\njava Ssurgeon -treebank trees/ -type interactive -patterns rules/ssurgeon-rules.xml","handlingStrategy":"validation","validationCode":"if (args == null || Arrays.stream(args).noneMatch(a -> a.equals(\"-patterns\"))) {\n  throw new IllegalArgumentException(\"-patterns is required\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  Ssurgeon.main(args);\n} catch (IllegalArgumentException e) {\n  log.error(\"Usage: Ssurgeon -patterns <rules> ...\");\n}","preventionTips":["Wrap Ssurgeon CLI runs in scripts that assert required flags exist","Echo the full command line before invocation","Check that path variables are non-empty before substituting into the command"],"tags":["cli","ssurgeon","arguments"],"backgroundTag":"missing-required-flag","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"}