languagetool-org/languagetool · error · IllegalArgumentException

Tagging makes no sense for profiling

Error message

Tagging makes no sense for profiling

What it means

parseOptions rejects -p/--profile together with -t/--tagger-only. Profiling times the rule-matching phase; tagger-only mode skips rules entirely, so profiling would have nothing meaningful to measure. IllegalArgumentException is thrown for the combination.

Source

Thrown at languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java:167

        }
      } else if (args[i].equals("-a") || args[i].equals("--apply")) {
        options.setApplySuggestions(true);
        if (options.isTaggerOnly()) {
          throw new IllegalArgumentException("You cannot apply suggestions when tagging only");
        }
        if (options.isJsonFormat()) {
          throw new IllegalArgumentException("JSON output format makes no sense for automatic application of suggestions");
        }
      } else if (args[i].equals("-p") || args[i].equals("--profile")) {
        options.setProfile(true);
        if (options.isJsonFormat()) {
          throw new IllegalArgumentException("JSON output format makes no sense for profiling");
        }
        if (options.isApplySuggestions()) {
          throw new IllegalArgumentException("Applying suggestions makes no sense for profiling");
        }
        if (options.isTaggerOnly()) {
          throw new IllegalArgumentException("Tagging makes no sense for profiling");
        }
      } else if (args[i].equals("--xmlfilter")) {
        options.setXmlFiltering(true);
      } else if (i == args.length - 1) {
        options.setFilename(args[i]);
      } else {
        throw new UnknownParameterException("Unknown parameter: " + args[i]);
      }
    }
    return options;
  }

  void printUsage() {
    printUsage(System.out);
  }

  void printUsage(PrintStream stream) {
    stream.println("Usage: java -jar languagetool-commandline.jar [OPTION]... FILE\n"

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Remove -t/--tagger-only when profiling so rules actually run and get timed
  2. Remove -p if you only need tagged output
  3. Profile the full pipeline (no -t) instead

Example fix

// before
languagetool -l en -p -t file.txt
// after
languagetool -l en -p file.txt   # profile rules
// or
languagetool -l en -t file.txt   # tag only
Defensive patterns

Strategy: validation

Validate before calling

if (hasFlag(args, "-p", "--profile") && hasFlag(args, "-t", "--tagger-only")) {
  throw new IllegalArgumentException("--profile requires rule matching; --tagger-only disables it");
}

Type guard

static boolean hasFlag(String[] args, String... names) {
  for (String a : args) for (String n : names) if (a.equals(n)) return true;
  return false;
}

Try / catch

try {
  options = CommandLineParser.parseOptions(args);
} catch (IllegalArgumentException e) {
  System.err.println(e.getMessage());
  System.exit(2);
}

Prevention

When it happens

Trigger: Command line contains both --profile (or -p) and --tagger-only (or -t), e.g. `languagetool -p -t file.txt`; checked in the profile branch via options.isTaggerOnly().

Common situations: Adding profiling to a tagging-only script to 'see what is slow'; combining benchmark flags with a tagger benchmark out of habit.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/7d051005c426f72c. Report an issue: GitHub.