voikko / corevoikko

Libvoikko and essential linguistic resources
Other
89 stars 25 forks source link

Where is pure-js libvoikko.js dist file? #31

Open Ciantic opened 7 years ago

Ciantic commented 7 years ago

Hello,

I downloaded the corevoikko release, but it does not seem to contain a file such as this: http://www.puimula.org/htp/testing/js-libvoikko/libvoikko.js which is pre-compiled.

It would be beneficial to include the pre-compiled libvoikko.js in the release zip.

I would like to create VSCode extension so I can spellcheck markdown right in the editor using this fine library. I've done a one VSCode extension, so it shouldn't be that hard.

Also been thinking about creating a crappy Chrome extension also, (crappy because the damn overlords at Chrome does not think it needs extension API 1, 2) it could work by injecting a script that communicates with extension in all pages instead.

hatapitk commented 7 years ago

The source code releases we ship are relly just for source code. So there will not be any pre-compiled files within them. I have been thinking about publishing libvoikko.js to npm repository but there are things to be done before that is possible. Meanwhile you can built the script yourself if you want to by using the shell scripts under https://github.com/voikko/corevoikko/tree/master/libvoikko/js . The "--preload-file 5" refers to a directory containing at least one dictionary in dictionary format 5, that needs to be manually placed under the directory where you call these scripts. Otherwise the scripts should do everything necessary automatically.

wiikka commented 6 years ago

+1. Is there way to build version for Node.js? Above mentioned libvoikko.js seems to rely on window, document, XMLHttpRequest etc, which are not available in Node.js.

hatapitk commented 6 years ago

@wiikka: your question is really more related to Emscripten than libvoikko. Libvoikko or our build scripts do not assume anything about the environment where the script is run. Emscripten needs to do some environment specific things and thus there are references to window etc. but that does not mean that the script would not run under Node.js. More info here: https://kripken.github.io/emscripten-site/docs/api_reference/module.html#overriding-execution-environment

wiikka commented 6 years ago

@hatapitk thanks for your answer. I actually already digged the Emscripten documents what you also suggested, but still couldn't make it run on Node.js. But nontheless I would like to see voikko as npm package in future. Thanks for great work and excellent library!

hatapitk commented 6 years ago

@wiikka I had to try that myself and indeed I forgot that --preload-file used in the build script does not work on Node. I tried with --embed-file and disabled closure compiler; now it works on Node:

$ node
> const Libvoikko = require('./js/libvoikko.js')()
> let v = Libvoikko.init("fi")
> v.analyze("alusta")
[ { BASEFORM: 'alustaa',
    CLASS: 'teonsana',
    FSTOUTPUT: '[Lt][Xp]alustaa[X]alusta[Tk][Ap][P2][Ny][Eb]',
    MOOD: 'imperative',
    NEGATIVE: 'both',
    NUMBER: 'singular',
    PERSON: '2',
    STRUCTURE: '=pppppp',
    TENSE: 'present_simple',
    WORDBASES: '+alustaa(alustaa)' },
  { BASEFORM: 'alku',
    CLASS: 'nimisana',
    FSTOUTPUT: '[Ln][Xp]alku[X]alu[Sela][Ny]sta',
    NUMBER: 'singular',
    SIJAMUOTO: 'sisaeronto',
    STRUCTURE: '=pppppp',
    WORDBASES: '+alku(alku)' },
  { BASEFORM: 'alus',
    CLASS: 'nimisana',
    FSTOUTPUT: '[Ln][Xp]alus[X]alu[Sp][Ny]sta',
    NUMBER: 'singular',
    SIJAMUOTO: 'osanto',
    STRUCTURE: '=pppppp',
    WORDBASES: '+alus(alus)' },
  { BASEFORM: 'alunen',
    CLASS: 'nimisana',
    FSTOUTPUT: '[Ln][Xp]alunen[X]alu[Sp][Ny]sta',
    NUMBER: 'singular',
    SIJAMUOTO: 'osanto',
    STRUCTURE: '=pppppp',
    WORDBASES: '+alunen(alunen)' },
  { BASEFORM: 'alusta',
    CLASS: 'nimisana',
    FSTOUTPUT: '[Ln][Xp]alusta[X]alust[Sn][Ny]a',
    NUMBER: 'singular',
    SIJAMUOTO: 'nimento',
    STRUCTURE: '=pppppp',
    WORDBASES: '+alusta(alusta)' } ]

Not the best way to do this on Node (would be even better to load the dictionary from actual file system). But at least we now know that it is possible. The difficulty of building the npm package is related to this issue: what is the best and most developer friendly way of handling the loading of dictionary files.

hatapitk commented 6 years ago

Meanwhile I wrote a bit more detailed instructions in our Wiki on how to build the library and optionally embed/preload the dictionaries for different environments: https://github.com/voikko/corevoikko/wiki/JavaScript

rkantos commented 5 years ago

Any developments regarding this? Shouldn't it already be possible to implement an extension to the most popular browsers using Chromium as their base? Personally I think the only way to get Google / Chromium project to get interested about developing proper support for spell checkers such as Voikko, is to make a very popular, but still "bad enough" extension, that more people will become knowledgeable about the downsides in Chrome, and start complaining, or even better, switching browsers :)

hatapitk commented 5 years ago

@rkantos I believe it should be possible to combine js-libvoikko and LanguageTool extensions for Chrome or Firefox to create a bad but working spell checker for these browsers: https://languagetool.org/#firefox_chrome Having the code in npm repository is not needed for this. We just need someone with some JavaScript experience and time (maybe just a day or two?) to try that.

niilo commented 5 years ago

It was quite journey to get emscripten up and running. So I created docker setup for JS transpilation https://github.com/niilo/libvoikko-js/tree/master/docker.

There's also Typescript typings for latest released version: https://github.com/niilo/libvoikko-js/tree/master/lib.

If I create pull request for Typescript typings and put those to /corevoikko/libvoikko/typescript? is it ok if I include that docker setup with instructions there also?

It would be nice to see this library released in npm. Is there something where community members can help? task list of issues that should be solved? Any restrictions to release with embeded language files?

hatapitk commented 5 years ago

Pull request for Typescript typings is Ok and very much appreciated! And any help getting this to npm too. You just need to find out a developer friendly way to handle dictionary loading so that it works in browser and on Node somehow. Now we build two versions for these use cases which may not be the best way to deal with the issue, just the best I could come up with at the time.

vepasto commented 3 years ago

I'm not able to get this working on browser. When I build it with the instructions mentioned above the libvoikko.js looks different than the example libvoikko.js. The example code works.

After build everything seems right and it loads data files, but when I run libvoikko.init('fi'), it throws error getpwuid_r: TODO

hatapitk commented 3 years ago

I will investigate this. You could try dowgrading Emscripten to an earlier version (late 2019 for example) to see if that helps.

to 7. tammik. 2021 klo 12.50 Veikko Karsikko notifications@github.com kirjoitti:

I'm not able to get this working on browser. When I build it with the instructions mentioned above the libvoikko.js looks different than the example libvoikko.js http://www.puimula.org/htp/testing/js-libvoikko/libvoikko.js. The example code works.

After build everything seems right and it loads data files, but when I run libvoikko.init('fi'), it throws error getpwuid_r: TODO

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/voikko/corevoikko/issues/31#issuecomment-756040895, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAONWOWUNY7EKKLS6C2HLDLSYWGXTANCNFSM4D7FXXYA .

vepasto commented 3 years ago

I will investigate this. You could try dowgrading Emscripten to an earlier version (late 2019 for example) to see if that helps. to 7. tammik. 2021 klo 12.50 Veikko Karsikko notifications@github.com kirjoitti: I'm not able to get this working on browser. When I build it with the instructions mentioned above the libvoikko.js looks different than the example libvoikko.js http://www.puimula.org/htp/testing/js-libvoikko/libvoikko.js. The example code works. After build everything seems right and it loads data files, but when I run libvoikko.init('fi'), it throws error getpwuid_r: TODO — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#31 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAONWOWUNY7EKKLS6C2HLDLSYWGXTANCNFSM4D7FXXYA .

I'll move this conversation into own issue as this is off topic.