Add grammar check via LanguageTool - #12831
ivandrofly wants to merge 1 commit into
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>
|
I also have https://languagetool.ivandrofly.org that any one can use or you can run your own https://github.com/Erikvl87/docker-languagetool |
|
Hi @ivandrofly, thanks a lot for the work on this - the tag/line-break handling and the cross-subtitle sentence joining are really nicely thought out, and the UI looks good. I'm going to close this one for now though. The main sticking point is the dependency on a LanguageTool server: either the text goes to the public API, or the user has to run a Java/Docker setup themselves, and neither fits well with where SE 5 is heading (everything running locally, no external services by default). Longer term I'm hoping we can do an AI-assisted port of the LanguageTool rule engine to C#, so the grammar check can run fully in-process with no server at all. If that materializes, a lot of what you built here - the annotated-text mapping, the fix application, the review grid - could come straight back, so please don't throw the branch away 🙂 Thanks again! |
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