emacs-languagetool / flycheck-languagetool Goto Github PK
View Code? Open in Web Editor NEWFlycheck support for LanguageTool
License: GNU General Public License v3.0
Flycheck support for LanguageTool
License: GNU General Public License v3.0
Hi,
Thanks for the great package. I am getting languagetool errors at my org documents' code blocks too. How would I disable flycheck to run spell checking at my code blocks?
Thanks
I'm working on a markdown file of 850 lines with no more than 100 characters per line (most of the file are code snippets) And got this error:
Debugger entered--Lisp error: (error "Error from syntax checker languagetool: peculiar e...")
error("Error from syntax checker languagetool: peculiar e...")
flycheck-languagetool--read-results((:error (error http 413) :peer (:certificates ((:version 3 :serial-number "04:32:23:0d:c0:e2:4b:c5:48:7a:a2:8e:e7:b9:d0:85:85..." :issuer "C=US,O=Let's Encrypt,CN=R3" :valid-from "2024-01-08" :valid-to "2024-04-07" :subject "CN=api.languagetool.org" :public-key-algorithm "EC/ECDSA" :certificate-security-level "High" :signature-algorithm "RSA-SHA256" :public-key-id "sha1:fc:a1:fe:82:43:48:85:8b:68:6e:72:6b:f7:45:d7:..." :certificate-id "sha1:a4:ff:e0:7a:47:de:34:0e:49:2b:13:39:fa:b7:4b:..." :pem "-----BEGIN CERTIFICATE-----\nMIIEKjCCAxKgAwIBAgISBD...") (:version 3 :serial-number "00:91:2b:08:4a:cf:0c:18:a7:53:f6:d6:2e:25:a7:5f:5a" :issuer "C=US,O=Internet Security Research Group,CN=ISRG Ro..." :valid-from "2020-09-04" :valid-to "2025-09-15" :subject "C=US,O=Let's Encrypt,CN=R3" :public-key-algorithm "RSA" :certificate-security-level "Medium" :signature-algorithm "RSA-SHA256" :public-key-id "sha1:8a:93:82:f4:c8:04:08:34:5e:5b:c2:f8:d7:55:d3:..." :certificate-id "sha1:a0:53:37:5b:fe:84:e8:b7:48:78:2c:7c:ee:15:82:..." :pem "-----BEGIN CERTIFICATE-----\nMIIFFjCCAv6gAwIBAgIRAJ...") (:version 3 :serial-number "40:01:77:21:37:d4:e9:42:b8:ee:76:aa:3c:64:0a:b7" :issuer "O=Digital Signature Trust Co.,CN=DST Root CA X3" :valid-from "2021-01-20" :valid-to "2024-09-30" :subject "C=US,O=Internet Security Research Group,CN=ISRG Ro..." :public-key-algorithm "RSA" :certificate-security-level "High" :signature-algorithm "RSA-SHA256" :public-key-id "sha1:f8:16:51:3c:fd:1b:44:9f:2e:6b:28:a1:97:22:1f:..." :certificate-id "sha1:93:3c:6d:de:e9:5c:9c:41:a4:0f:9f:50:49:3d:82:..." :pem "-----BEGIN CERTIFICATE-----\nMIIFYDCCBEigAwIBAgIQQA...")) :certificate (:version 3 :serial-number "04:32:23:0d:c0:e2:4b:c5:48:7a:a2:8e:e7:b9:d0:85:85..." :issuer "C=US,O=Let's Encrypt,CN=R3" :valid-from "2024-01-08" :valid-to "2024-04-07" :subject "CN=api.languagetool.org" :public-key-algorithm "EC/ECDSA" :certificate-security-level "High" :signature-algorithm "RSA-SHA256" :public-key-id "sha1:fc:a1:fe:82:43:48:85:8b:68:6e:72:6b:f7:45:d7:..." :certificate-id "sha1:a4:ff:e0:7a:47:de:34:0e:49:2b:13:39:fa:b7:4b:..." :pem "-----BEGIN CERTIFICATE-----\nMIIEKjCCAxKgAwIBAgISBD...") :key-exchange "ECDHE-RSA" :protocol "TLS1.3" :cipher "AES-256-GCM" :mac "AEAD" :encrypt-then-mac nil)) #<buffer core.md> #f(compiled-function (&rest args) #<bytecode -0x13327cfdd83823e6>))
url-http-activate-callback()
url-http-content-length-after-change-function(296 406 110)
url-http-wait-for-headers-change-function(1 415 414)
url-http-generic-filter(#<process api.languagetool.org> "HTTP/1.1 413 Request Entity Too Large\15\nserver: nginx/1.24.0\15\ndate: Thu, 29 Feb 2024 16:29:05 GMT\15\ncontent-length: 109\15\naccess-control-allow-origin: *\15...")
Is there a way to split the payload when it's too big and send it via a few requests?
Hello!
Can you please provide something like this flymake-languagetool.el#L80-L84?
In flymake-languagetool
, there is an option to use a custom LanguageTool command instead of languagetool-server.jar
, this is extremely useful for distributions which provide LanguageTool packages (like Arch Linux).
See emacs-languagetool/flymake-languagetool#6 for reference.
Thank you !
Same issue (regarding wrong column and row numbers) as in emacs-grammarly/flycheck-grammarly#13. This also happens with flymake-languagetool.
This is a screenshot:
Hi,
Suppose I have a text buffer or a file with the following content.
This text has bug but LanguageTool do not finds it.
The flycheck checkers are set as follows.
First checker to run:
languagetool
- may enable: yes
- LanguageTool server JAR: Found at /home/swarnendu/.emacs.d/etc/languagetool-server.jar
- LanguageTool API URL: Not configured
- next checkers: proselint
I do not use proselint
and have disabled it, so the rest of the Flycheck checkers
buffer should not be relevant.
Flycheck-languagetool
throws the following error when I invoke flycheck-buffer
.
Error from syntax checker languagetool: peculiar error: "deleted
", :host, "localhost", :service, 8081
error in process sentinel: flycheck-languagetool--read-results: peculiar error: "deleted
", :host, "localhost", :service, 8081
error in process sentinel: peculiar error: "deleted
", :host, "localhost", :service, 8081
error in process sentinel: flycheck-languagetool--read-results: peculiar error: "failed with code 111
", :host, "localhost", :service, 8081
error in process sentinel: peculiar error: "failed with code 111
", :host, "localhost", :service, 8081
Error from syntax checker languagetool: peculiar error: "deleted
", :host, "localhost", :service, 8081
error in process sentinel: flycheck-languagetool--read-results: peculiar error: "deleted
", :host, "localhost", :service, 8081
error in process sentinel: peculiar error: "deleted
", :host, "localhost", :service, 8081
error in process sentinel: flycheck-languagetool--read-results: peculiar error: "failed with code 111
", :host, "localhost", :service, 8081
error in process sentinel: peculiar error: "failed with code 111
", :host, "localhost", :service, 8081
Here is my flycheck-languagetool
configuration.
;; https://languagetool.org/download/
(use-package flycheck-languagetool
:after flycheck
:defines (flycheck-languagetool-commandline-jar flycheck-languagetool-check-time)
:demand t
:config
(setq flycheck-languagetool-commandline-jar (no-littering-expand-etc-file-name
"languagetool-commandline.jar")
flycheck-languagetool-server-jar (no-littering-expand-etc-file-name
"languagetool-server.jar")
flycheck-languagetool-check-time 3))
When flyspell-mode is active, spellchecking is disabled for languagetool (which is a nice feature). However, this injects a disabledRules command to the query that overrides any possibility to add more disabledRules. Current workaround is to modify the internal variable flycheck-languagetool--spelling-rules to add the disabled check.
Proposed solution: Add a new customisation variable flycheck-languagetool-disabled-rules (list of strings).
Here is my config (which works fine):
(use-package flycheck-languagetool
:hook
(text-mode . flycheck-languagetool-setup)
(org-mode . flycheck-languagetool-setup)
(latex-mode . flycheck-languagetool-setup)
(markdown-mode . flycheck-languagetool-setup)
:init
(setq flycheck-languagetool-url "https://api.languagetool.org")
(setq flycheck-languagetool-server-jar nil)
(setq flycheck-languagetool-server-port nil)
(setq flycheck-languagetool-language "fr-FR")
:config
(add-to-list 'flycheck-checkers 'languagetool)
)
How could I add (setq flycheck-languagetool-language "en-US")
?
I get either this error:
File mode specification error: (error Autoloading file /home/titan/.emacs.d/elpa/flycheck-languagetool-20220731.2301/flycheck-languagetool.elc failed to define function flycheck-languagetool-steup)
Or I get the following error:
run-hooks: Autoloading file /home/titan/.emacs.d/elpa/flycheck-languagetool-20220731.2301/flycheck-languagetool.elc failed to define function flycheck-languagetool-steup
I'm not terribly elisp savvy, this is the extent of my config with flycheck-languagetool:
(use-package flycheck-languagetool
:after (flycheck langtool langtool-ignore-fonts)
:custom (flycheck-languagetool-url "localhost")
:hook ((text-mode LaTeX-mode markdown-mode) . flycheck-languagetool-steup))
If I try to invoke the function manually, it doesn't seem to do anything. I mostly work in LaTeX where I'd want grammar checking, and I wonder if LSP is overriding that.
If I call languagetool from the langtool package, it works as expected.
If a buffer is not visiting a file (i.e., when buffer-file-name
is nil
) the languagetool Flycheck checker appears to be active, but no errors are highlighted.
If a buffer is visiting a file but that file has not been saved recently (i.e., when (buffer-modified-p)
is t
), errors are shown for the file as it is on disk, not as it is in the buffer.
I am encountering this bug, languagetool-org/languagetool#3666.
Many thanks for this package! My only issue with it so far is that currently it sends the entire buffer to languagetool, which means my 6000 line org files will basically never be checked and I will always have 100% CPU while having them open. It would be great if you could make it only send the contents on screen, current line, etc. Flyspell already does this although it gets away with only sending the current word since it's only a spell-checker
I find that my CPU is unusually busy when using flycheck-languagetool.
I notice that languagetool-commandline.jar
takes a long time to start up, even if there is no work for it to do. We pay this cost every time the check runs.
$ time java -jar languagetool-commandline.jar /dev/null
No language specified, using English (no spell checking active, specify a language variant like 'en-GB' if available)
Working on /dev/null...
Time: 76ms for 0 sentences (0.0 sentences/sec)
real 0m2.838s
user 0m11.031s
sys 0m0.255s
If we were to use languagetool-server.jar
instead, subsequent checks would be much faster:
$ java -cp languagetool-server.jar org.languagetool.server.HTTPServer
$ time curl --data "language=en-GB&text=" http://localhost:8081/v2/check
{"software":{"name":"LanguageTool","version":"5.3","buildDate":"2021-03-29 11:16:13 +0000","apiVersion":1,"premium":false,"premiumHint":"You might be missing errors only the Premium version can find. Contact us at support<at>languagetoolplus.com.","status":""},"warnings":{"incompleteResults":false},"language":{"name":"English (GB)","code":"en-GB","detectedLanguage":{"name":"English (US)","code":"en-US","confidence":0.0}},"matches":[]}
real 0m2.365s
user 0m0.005s
sys 0m0.007s
$ time curl --data "language=en-GB&text=" http://localhost:8081/v2/check
{"software":{"name":"LanguageTool","version":"5.3","buildDate":"2021-03-29 11:16:13 +0000","apiVersion":1,"premium":false,"premiumHint":"You might be missing errors only the Premium version can find. Contact us at support<at>languagetoolplus.com.","status":""},"warnings":{"incompleteResults":false},"language":{"name":"English (GB)","code":"en-GB","detectedLanguage":{"name":"English (US)","code":"en-US","confidence":0.0}},"matches":[]}
real 0m0.064s
user 0m0.006s
sys 0m0.006s
Right now when I have a spelling mistake I only see this message:
Possible spelling mistake found. [(MORFOLOGIK_RULE_EN_US)]
It doesn't explain how to fix the error. If I don't know how to spell it I need to copy and paste into the browser to see suggestion.
I'm running a system providing a languatetool service. It's available at http://localhost:8081/v2/check
. I've tried setting flycheck-languagetool-url
, but it doesn't work. What's the proper way to use it instead of starting a new process?
Hi,
Thanks a lot for this package!
I wondered if it was possible to have a mode similar to flyspell-prog-mode to check grammars in source code comments, doc and strings.
Thanks for putting this package together ๐
After I configured Emacs according to the instructions given in the README, I opened a text file, and ran flycheck-mode
. After doing this, Flycheck reports: no checker. Am I missing something?
LanguageTool (LT) can be picky about markup, which increases false positives. I think for now, I can probably ignore it, but I wanted to create an issue to document what I've tried and see if there's any interest in pursuing a better solution (as my solution is neither good nor complete).
Authoring papers, I would like to be able to integrate LT into my workflow, of the options, I like the flycheck version the most. However, since I often author papers in \LaTeX or similar, I would prefer to remove the markup before passing the text to LT. To that effect, I've created a function, detex-filter
:
(defun detex-filter (contents)
"Return buffer contents without (La)TeX commands via `detex'."
(with-temp-buffer
(goto-char (point-min))
(insert contents)
(call-process-region (point-min) (point-max) program t t)
(buffer-substring-no-properties (point-min) (point-max))))
And I modified the POST parameters in flycheck-languagetool--start
:
- ("text" . ,(buffer-substring-no-properties
+ ("text" . ,(detex-filter (buffer-substring-no-properties
And this "works" for false alarms like \textit{e.g.,}
for example. However, there are two issues that this raises: one, how to map points back to the real source? For example, detex
filters out the correct expressions in a sentence, transforming something like "\acl{AI}\cite{reference} supports many tasks." to "AI supports many tasks". But now the warning about "many" not being the right quantifier maps onto \cite, which is the wrong point within the original buffer. It is likely my ignorance, but I'm not aware of the correct way of handling these kinds of mapping issues.
Two, extensibility. LT is helpful in more than just \LaTeX modes. Therefore, there needs to be a way to select an appropriate (set of) filter(s) for the current mode. Also likely a lack of knowledge, so there may be solid existing solutions to this, but my limited look at other flycheck checkers didn't turn up anything.
Thoughts?
Hi, I'm looking for a grammar checker for LaTeX files.
It seems this package is not on Melpa yet.
Can I use it now?
I'm also curious if this tool can work on LaTeX files.
Thanks for making this package.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.