languagetool-org/languagetool · error · IllegalArgumentException
You cannot list unknown words when tagging only
Error message
You cannot list unknown words when tagging only
What it means
parseOptions() enforces flag exclusivity: `-u/--list-unknown` cannot be combined with `-t/--taggeronly`. When --taggeronly is parsed and list-unknown was already set (options.isListUnknown()), it throws IllegalArgumentException. Tag-only mode just tags text and does not run the spell checker that produces unknown-word lists, so the combination is rejected.
Source
Thrown at languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java:66
} else if (args[i].equals("-v") || args[i].equals("--verbose")) {
options.setVerbose(true);
} else if (args[i].equals("--line-by-line")) {
options.setLineByLine(true);
} else if (args[i].equals("--enable-temp-off")) {
options.setEnableTempOff(true);
} else if (args[i].equals("--clean-overlapping")) {
options.setCleanOverlapping(true);
} else if (args[i].equals("--level")) {
String level = args[++i];
try {
options.setLevel(JLanguageTool.Level.valueOf(level));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Unknown level '" + level + "' - currently, only 'PICKY' is supported");
}
} else if (args[i].equals("-t") || args[i].equals("--taggeronly")) {
options.setTaggerOnly(true);
if (options.isListUnknown()) {
throw new IllegalArgumentException("You cannot list unknown words when tagging only");
}
if (options.isApplySuggestions()) {
throw new IllegalArgumentException("You cannot apply suggestions when tagging only");
}
} else if (args[i].equals("-r") || args[i].equals("--recursive")) {
options.setRecursive(true);
} else if (args[i].equals("-b2") || args[i].equals("--bitext")) {
options.setBitext(true);
} else if (args[i].equals("-eo") || args[i].equals("--enabledonly")) {
if (options.getDisabledRules().size() > 0) {
throw new IllegalArgumentException("You cannot specify both disabled rules and enabledonly");
}
options.setUseEnabledOnly();
} else if (args[i].equals("-d") || args[i].equals("--disable")) {
if (options.isUseEnabledOnly()) {
throw new IllegalArgumentException("You cannot specify both disabled rules and enabledonly");
}
checkArguments("-d/--disable", i, args);View on GitHub (pinned to 2e990059ce)
Solutions
- Remove -u/--list-unknown if you want tagger-only mode.
- Remove -t/--taggeronly if you want the unknown-words list.
- Run two separate invocations if you need both behaviors.
Example fix
// before languagetool -t -u -l en file.txt // after languagetool -t -l en file.txt
Defensive patterns
Strategy: validation
Validate before calling
boolean hasTaggerOnly = Arrays.asList(args).contains("-t") || Arrays.asList(args).contains("--taggeronly");
boolean hasListUnknown = Arrays.asList(args).contains("-u") || Arrays.asList(args).contains("--list-unknown");
if (hasTaggerOnly && hasListUnknown) throw new IllegalArgumentException("-t and -u are mutually exclusive"); Try / catch
try {
new CommandLineParser().parseOptions(args);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("list unknown words when tagging only")) {
System.err.println("Remove either -t/--taggeronly or -u/--list-unknown.");
}
} Prevention
- Never combine -t and -u in generated command lines.
- Keep flags in one place in wrapper scripts so exclusivity is visible.
- Test generated argument lists before production use.
When it happens
Trigger: `languagetool -t -u file.txt` (or the long forms --taggeronly --list-unknown) with -u appearing before -t on the command line.
Common situations: Script merging two previous invocations' flags; users assuming the flags are independent; documentation examples concatenated.
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
- You cannot apply suggestions when tagging only
- You cannot specify both disabled rules and enabledonly
- JSON output format makes no sense for automatic application
- JSON output format is not implemented for "line by line" ana
- JSON output format is not implemented for Bitext
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/4c9fa202eaad17fd.
Report an issue: GitHub.