Add grammar check via LanguageTool - #12831
Open
ivandrofly wants to merge 1 commit into
Open
Conversation
New Tools window that checks the subtitle against a LanguageTool server - the public API or a self-hosted one - and applies the fixes you tick. Formatting tags, ASSA override blocks, music symbols and the line break inside a subtitle are sent as markup, so LanguageTool neither checks nor counts them, while the offsets it answers with still point into the original line - a fix lands exactly where it belongs and the tags stay untouched. Issues spanning a tag or a line break are dropped rather than applied. Lines whose sentence continues into the next subtitle are checked as one sentence, so errors spread over two lines are found. The client and the offset mapping live in libuilogic so the command line converter can use them later; the window reuses the AI review category vocabulary, colours and diff highlighting. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
|
I also have https://languagetool.ivandrofly.org that any one can use or you can run your own https://github.com/Erikvl87/docker-languagetool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A new Tools → Grammar check (LanguageTool)… window that checks the subtitle against a LanguageTool server - the public API or a self-hosted one (e.g. the docker image) - and applies the fixes the user ticks. It complements AI review: rule based, so it points at an exact span and offers concrete replacements instead of rewriting a line, it is much faster, and with a self-hosted server the text never leaves the machine.
src/libuilogic/Grammar/—LanguageToolClient(/v2/check,/v2/languages, picky level, disabled rules, optional premium credentials),LanguageToolAnnotatedText(builds the annotated document and maps the answer back),LanguageToolFix(applies several fixes to one line). Kept out of the UI project soseconvcan use it later.src/ui/Features/Tools/GrammarCheck/— the window and its view models. Server box with a test-connection button, language list served by the server (defaulting to the auto-detected subtitle language), picky toggle, category filter chips, a checkbox grid with before/after diffs, a replacement picker for the selected row, and a small settings dialog for user name / API key / disabled rules / lines per request.Se.Settings.Tools.GrammarCheck, localizable strings, and a docs page.Formatting tags, ASSA override blocks, music symbols and the line break inside a subtitle are sent as
markup, so LanguageTool neither checks nor counts them as words, while the offsets it returns still point into the original line - a fix lands exactly where it belongs and the tags stay untouched. An issue spanning a tag or a line break is dropped rather than applied. Lines whose sentence continues into the next subtitle are joined withinterpretAs, so a sentence is checked the way it reads on screen and agreement errors spread over two lines are found; fixes are still applied per line, so timing and reading speed are unaffected.Nothing is applied automatically: spelling/grammar/punctuation/casing fixes start ticked, style suggestions start unticked, and rules that offer no replacement cannot be ticked at all.
Test plan
<i>He go to school</i>/I has a apple- issues appear per line with category tags and before/after diffs<i>…</i>or starting with{\an8}keeps its tags after applying a fix inside itUI
🤖 Generated with Claude Code