Findus23/pyLanguagetool

Split large text bodies into multiple API requests

Closed this issue · 2 comments

Hi there,

I am a longtime LanguageTool user and I just stumbled across your library (thanks btw!).
While trying to incorporate this tool into my workflow, I came across the following error:

ValueError: Error: Your text exceeds the limit of 20000 characters (it's 25869 characters). Please submit a shorter text.

Now, I'm not familiar with the internal workings of the LanguageTool API, but would it be possible to split large text bodies into smaller chunks and to send multiple API requests?

Hi,

I am glad this is helpful to you!

I think the 20K character limit is neither by pylanguagetool nor by languagetool itself. Instead, it is by the hosted instance on languagetool.org to reduce the server load by free users.

So if you instead use your own languagetool-server (e.g. by running https://dev.languagetool.org/http-server on localhost) then you can use arbitrary long texts.

➜  ~ python -c "print('a'*50000)" | pylanguagetool
filetype not detected, assuming plaintext
Tagalog detected (100% confidence)

Text checked by https://mylanguagetool.example/v2/ (LanguageTool 6.2)

Good to know, that works for me too! Thanks!