Configure Grammar Check

Hi,

I just installed the new version (22.05.3 from repo, I use COOL from Nextcloud) and as I see that it is possible to integrate with LanguageTool (advertised at launch, on Nextcloud side), I choose to give it a try. So far, I’ve got so little results that I even doubt it is implemented.

I installed the LanguageTool java server running with the command :

java -cp languagetool-server.jar org.languagetool.server.HTTPServer --port 8082 --al
low-origin '*' --public

I try to send notification from multiple configurations :

  • Directly (HTTPlocalhost:8082)
  • Directly from the internet (HTTPmydomain:8082)
  • Through an Nginx SSL proxy on the same subdomain as coolwsd (HTTPSsub.mydomain/lt/)

On all of theses scenarios, I can check with curl that it work :

$ curl -d "language=fr" -d "text=j'aurais pas cru" HTTPSsub.mydomain/lt/v2/check
{"software":{"name":"LanguageTool","version":"5.7","buildDate":"2022-03-28 18:24:41 +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":"French","code":"fr","detectedLanguage":{"name":"French","code":"fr","confidence":0.9990271}},"matches":[{"message":"Un adverbe de négation doit être ajouté afin d’obtenir une négation complète.","shortMessage":"","replacements":[{"value":"je n'aurais"}],"offset":0,"length":8,"context":{"text":"j'aurais pas cru","offset":0,"length":8},"sentence":"j'aurais pas cru","type":{"typeName":"Other"},"rule":{"id":"P_V_PAS","subId":"1","sourceFile":"grammar.xml","description":"négation sans NE","issueType":"uncategorized","urls":[{"value":"HTTPwww.academie-francaise.fr/ne"}],"category":{"id":"CAT_GRAMMAIRE","name":"Grammaire"}},"ignoreForIncompleteSentence":true,"contextForSureMatch":15}]}

From both local and remote sources.

I tryed to configure coolwsd by setting the endpoint as default :

  <languagetool desc="LanguageTool Remote API settings for grammar checking">
    <enabled desc="Enable LanguageTool Remote Grammar Checker" type="bool" default="false">true</enabled>
    <base_url desc="Http endpoint for the LanguageTool API server, without /check or /languages postfix at the end." type="string" default="PROTOSsub.mydomain/lt/v2/"></base_url>
   [...]
  </languagetool>

And by modifying the way the XML is formatted :

  <languagetool desc="LanguageTool Remote API settings for grammar checking">
    <enabled desc="Enable LanguageTool Remote Grammar Checker" type="bool" default="false">true</enabled>
    <base_url desc="Http endpoint for the LanguageTool API server, without /check or /languages postfix at the end." type="string" default="">PROTOSsub.mydomain/lt/v2/</base_url>
   [...]
  </languagetool>

For every different configuration, I also tried to trigger LT by launching a manual spellcheck (and confirmed that the “check grammar” is on).

So far, the LanguageTool HTTP Server never saw a request from coolwsd or a Nextcloud client (I don’t know from which one I should wait a request).

I also switch logs to debug on coolwsd’s side and didn’t see anything that seem related to LanguageTool and I didn’t see anything either from my browser’s inspector (both Chromium and Firefox ESR).

I suppose it’s on me but I don’t know what I miss. Any clue ?

EDIT: PROTO is http:// and PROTOS is https://, I just it the “2 links” limit.

Hello and welcome to the forum @sedric ! Thanks for taking the time to test the brand new features in this release, you rock :slight_smile:

I see, you are using your own LanguageTool java server, I think that should have worked but maybe @merttumer can give a hand here (?)

@merttumer did check this post:

“there is no problem on the instruction as it seems. Everything seems fine. Not sure why it doesn’t work. Hm…We need to know if he uses docker for COOL and try to reach a host from outside the container, in that case it may fail of course.”

Hi,

No, I don’t use docker, but I have a proxy to access the nextcloud host. and I can access the LT Server from both localhost, proxy and a client.

Here is a little schema if it’s easier to represent than my explanations :

          domain.tld (NC)         cloud.local                          
          sub.domain.tld         +-----------------------------------+
           (CooL  / LT)          | Nextcloud:80                      |
            +--------+           |   (through Apache)                |
            |        |           | CooL:9980                         |
            | Proxy  +-----------+   (direct, installed with apt)    |
            |        |           | LanguageTool:8081                 |
            +--------+           |   (direct, manually copied jar)   |
curl sub.domain.tld/lt/v2/ OK    +-----------------------------------+
curl cloud.local:8081      OK     curl cloud.local:8081      OK
Browser throught Nextcloud KO     curl sub.domain.tld/lt/v2/ OK
                                  Browser throught Nextcloud Not tested

And the proxy config for LanguageTool :

proxy_redirect          off;
proxy_set_header        Host            $host;
proxy_set_header        X-Real-IP       $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size    10m;
client_body_buffer_size 128k;
proxy_connect_timeout   90;
proxy_send_timeout      90;
proxy_read_timeout      90;
proxy_buffer_size   16k;
proxy_buffers       32   16k;
proxy_busy_buffers_size 64k;

location ~* ^/lt/(.*)
  {
    proxy_pass http://cloud.local:8081/$1$is_args$args;
  }

When I try from NC/CooL, I don’t have entries on the NGinx proxy and LT Server saying that there is a query. Nextcloud or CooL log say nothing that seems relevant about LanguageTool (no mention of “LanguageTool”, “grammar”, “LT” or the URL configured in coolwsd).

But if the config seems right, maybe I should try filling a bug report on GitHub instead ?

@sedric
I see that in the coolwsd.xml
<base_url desc="Http endpoint for the LanguageTool API server, without /check or /languages postfix at the end." type="string" default="">PROTOSsub.mydomain/lt/v2/</base_url>
you did not use http:// or https:// at the start of “PROTOSsub.mydomain/lt/v2/”
LanguageTool plugin in the COOL uses libcurl and it needs to have http:// or http:// at the beginning, or else it may not do the request.
Unless you try that already, can you please check again? If this wont fix your problem we can move this to github issues :slight_smile:

Thank you so much for the feedback

As I said at the bottom of the first post, I replaced every http:// and https:// by PROTO and PROTOS to avoid hitting the link limit per post on the forum.

But I didn’t tried to connect in HTTP trough the proxy before, I just test and it doesn’t work either.

I’ll open a github issue.

1 Like

Yes please do so, thanks @sedric for all your time testing this out!

could you check this @merttumer Selfhosted grammar check does not work · Issue #5016 · CollaboraOnline/online · GitHub ?