NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.52k stars 13k forks source link

languagetool: desn't work with language other than english. #21283

Open mikefaille opened 7 years ago

mikefaille commented 7 years ago

Issue description

Work with English corrector but not using spanish or french one.

java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: Unable to load library '/tmp/jna8713236742918782736.libhunspell-linux-x86-64.so': Native library (tmp/jna8713236742918782736.libhunspell-linux-x86-64.so) not found in resource path ([file:/nix/store/qmfzxscl7qj4141l1ymnkp281p56jr11-LanguageTool-3.5/share/languagetool.jar])
    at org.languagetool.MultiThreadedJLanguageTool.performCheck(MultiThreadedJLanguageTool.java:176)
    at org.languagetool.JLanguageTool.check(JLanguageTool.java:546)
    at org.languagetool.JLanguageTool.check(JLanguageTool.java:496)
    at org.languagetool.JLanguageTool.check(JLanguageTool.java:492)
    at org.languagetool.gui.LanguageToolSupport.checkText(LanguageToolSupport.java:755)
    at org.languagetool.gui.LanguageToolSupport.access$2200(LanguageToolSupport.java:59)
    at org.languagetool.gui.LanguageToolSupport$RunnableImpl.run(LanguageToolSupport.java:921)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.languagetool.MultiThreadedJLanguageTool.performCheck(MultiThreadedJLanguageTool.java:173)
    ... 13 more
Caused by: java.lang.UnsatisfiedLinkError: Unable to load library '/tmp/jna8713236742918782736.libhunspell-linux-x86-64.so': Native library (tmp/jna8713236742918782736.libhunspell-linux-x86-64.so) not found in resource path ([file:/nix/store/qmfzxscl7qj4141l1ymnkp281p56jr11-LanguageTool-3.5/share/languagetool.jar])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Library$Handler.<init>(Library.java:147)
    at com.sun.jna.Native.loadLibrary(Native.java:412)
    at com.sun.jna.Native.loadLibrary(Native.java:391)
    at org.languagetool.rules.spelling.hunspell.Hunspell.<init>(Hunspell.java:127)
    at org.languagetool.rules.spelling.hunspell.Hunspell.getInstance(Hunspell.java:68)
    at org.languagetool.rules.spelling.hunspell.Hunspell.getInstance(Hunspell.java:54)
    at org.languagetool.rules.spelling.hunspell.HunspellRule.init(HunspellRule.java:183)
    at org.languagetool.rules.spelling.hunspell.HunspellRule.match(HunspellRule.java:83)
    at org.languagetool.JLanguageTool.checkAnalyzedSentence(JLanguageTool.java:629)
    at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:976)
    at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:928)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    ... 3 more

Steps to reproduce

Technical details

jgeerds commented 7 years ago

Interesting... it works with nixpkgs-unstable but not release-16.09. The /tmp/jna8713236742918782736.libhunspell-linux-x86-64.so exists in both cases.

alexeymuranov commented 7 years ago

I observed a probably related issue: i have installed several hunspell dictionaries, but only en_US (hunspell-dict-en-us-wordlist-2014.11.17) got recognised by applications such as Evolution email client, not even other English dictionaries (en_GB-ise, en_GB-ize).

Is this the same issue? What could make en_US special?

pbogdan commented 7 years ago

@alexeymuranov how did you install hunspell and the dictionaries? what does $ hunspell -D say?

alexeymuranov commented 7 years ago

@pbogdan, to get English (United States) appear in spell checking preferences in Evolution, it is enough to do

nix-env -i hunspell-dict-en-us-wordlist-2014.11.17

Not even installing hunspell is necessary.

Here is what i actually have:

§ nix-env -q | grep hunspell
hunspell-1.3.3
hunspell-dict-en-gb-ise-wordlist-2014.11.17
hunspell-dict-en-gb-ize-wordlist-2014.11.17
hunspell-dict-en-us-wordlist-2014.11.17
hunspell-dict-fr-any-dicollecte-5.3
hunspell-dict-fr-moderne-dicollecte-5.3
§ hunspell -D
SEARCH PATH:
.::/usr/share/hunspell:/usr/share/myspell:/usr/share/myspell/dicts:/Library/Spelling:/home/alexey/.openoffice.org/3/user/wordbook:.openoffice.org2/user/wordbook:.openoffice.org2.0/user/wordbook:Library/Spelling:/opt/openoffice.org/basis3.0/share/dict/ooo:/usr/lib/openoffice.org/basis3.0/share/dict/ooo:/opt/openoffice.org2.4/share/dict/ooo:/usr/lib/openoffice.org2.4/share/dict/ooo:/opt/openoffice.org2.3/share/dict/ooo:/usr/lib/openoffice.org2.3/share/dict/ooo:/opt/openoffice.org2.2/share/dict/ooo:/usr/lib/openoffice.org2.2/share/dict/ooo:/opt/openoffice.org2.1/share/dict/ooo:/usr/lib/openoffice.org2.1/share/dict/ooo:/opt/openoffice.org2.0/share/dict/ooo:/usr/lib/openoffice.org2.0/share/dict/ooo
AVAILABLE DICTIONARIES (path is not mandatory for -d option):
Can't open affix or dictionary files for dictionary named "en_US".
22:54:00[alexey@Alexey-BU403UA-NixOS:~]
pbogdan commented 7 years ago

@alexeymuranov this looks similar to an issue I had when setting up hunspell to be used as spellchecker in emacs. Initially I installed hunspell and dictionaries by referencing package names directly like you did but that would give me an installation where the dictionaries were not included in hunspell's search path. What worked for me was instead using hunspellWithDicts From shell you should be able to use it as follows:

$ nix-instantiate -E 'with import <nixpkgs> { }; hunspellWithDicts [ hunspellDicts.en-gb-ise ]'
warning: you did not specify ‘--add-root’; the result might be removed by the garbage collector
/nix/store/9ha2k5wpz8a5akl4py1836mbyk85fj7b-hunspell-with-dicts-1.3.3.drv
$ nix-env -i /nix/store/9ha2k5wpz8a5akl4py1836mbyk85fj7b-hunspell-with-dicts-1.3.3.drv

That should give you hunspell which has all the extra dictionaries included in the search path by default. Not sure but you may also need to first uninstall the currently installed hunspell and dictionaries. For installing via ~/.config/nixpkgs.nix you can add:

myhunspell = hunspellWithDicts [ hunspellDicts.en-gb-ise ];

within packageOverrides section and then reference myhunspell within your package set. Also not sure about Evolution but I found it easiest to set a default dictionary with an environment variable like so:

export DICTIONARY=en_GB-ise

HTH.

alexeymuranov commented 7 years ago

@pbogdan, i tried with ~/.config/nixpkgs.nix:

{ #...
  myHunspell = hunspellWithDicts [
    hunspellDicts.en-gb-ise
    hunspellDicts.en-gb-ize
    hunspellDicts.en-us
    hunspellDicts.fr-any
    hunspellDicts.fr-moderne
  ];
}
nix-env -iA nixos.myHunspell

(after uninstalling everything for Hunspell), but still in Evolution i only see Hebrew (?).

matthew-piziak commented 5 years ago

unstable.hunspellWithDicts [ unstable.hunspellDicts.en-us ]; still breaks on "isn't":

Hunspell 1.7.0
isn't
& isn 9 0: sin, ins, ism, is, in, inn, ion, isl, is n
*
stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
MMesch commented 2 years ago

This in home manager worked for me:

    languagetool
  (myHunspell = hunspellWithDicts [
    hunspellDicts.en-gb-ise
    hunspellDicts.en-gb-ize
    hunspellDicts.en-us
    hunspellDicts.fr-any
    hunspellDicts.fr-moderne
  ])
patka-123 commented 7 months ago

Hello @mikefaille :wave:

I tried to reproduce this issue, but it seems like everything seems to be working. Is this still an issue you experience? If not, would you be able to close this issue?

(I'm going through issues marked as stale to see what can be resolved. If this is still an issue that you have then don't mind me).