Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to have a task-specific spelling.txt that can be supplied as a parameter to the CLI? #11204

Open
ralienpp opened this issue Jan 22, 2025 · 1 comment

Comments

@ralienpp
Copy link

ralienpp commented Jan 22, 2025

I am trying to put together a prototype that leverages LanguageTool to check the grammar and style of strings and comments in source code files (Python, in my example).

There is a tool that preprocesses the source code and extracts all relevant strings into a separate file, called result.txt. This file is then fed into LanguageTool like so java -jar languagetool-commandline.jar -l en-US --line-by-line --disable WHITESPACE_RULE result.txt.

Generally, it works, but there are a lot of complaints that could have been avoided, if I could explicitly tell LanguageTool which words are correct as they are. For example, consider this output:

2.) Line 187, column 90, Rule ID: MORFOLOGIK_RULE_EN_US premium: false prio=-10
Message: Possible spelling mistake found.
Suggestion: bad Request
...ed names representing failure info, such as `badRequest`.         Defaults to `None`.         - `tex...
                                                ^^^^^^^^^^

3.) Line 189, column 61, Rule ID: MORFOLOGIK_RULE_EN_US premium: false prio=-10
Message: Possible spelling mistake found.
...s`: A list of or a single text used for the `PKIStatusText` structure. Defaults to         `"This text ...
                                                ^^^^^^^^^^^^^

In the business logic of my program, the terms "badRequest" and "PKIStatusText" are correct.

I've read that I can address this problem by updating my spelling.txt in org\languagetool\resource\en\hunspell. Although it does the trick, my concern is that I am making a global change. The terms in question are fine for program X, but they're not applicable to another program I work on. Ideally, there ought to be a way to pass the path to my custom spelling.txt as an argument to languagetool-commandline.jar, such that I can apply different exceptions to different projects.

How can this be accomplished? Or perhaps there is a better alternative that I am unaware of?

@danielnaber
Copy link
Member

I don't think there's such a feature. Your best bet is to think of LT as a library and use its output as the input for your own filtering layer that removes these matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants