voikko / corevoikko

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

Building voikko to be used in Javascript/Typescript apps seems to need some update #56

Closed lehtu closed 9 months ago

lehtu commented 10 months ago

I am building a REST API with Javascript/Typescript and for that I would like to use Voikko, and I have no experience with it beforehand, and I have encountered several problems with it.

First of all the latest working version seems to be 4 years old from @niilo . But since this core package has got updates after that, I would like to use the latest version, which means that needs to be build manually.

I found and read the documentation that has been updated 2018 and for example, there is this line source ~/emscripten/emsdk_portable/emsdk_set_env.sh and I haven't been able to track down which emscripten version had that kind of hierarchy.

In the Libvoikko-demo site in the footer it says that version 1.37.35 has been used, and the actual link form the version to emscripten site suggests to use emsdk, which oldest version is 1.38.48 and latest 3.1.51.

I believe I have now tried latest and the oldest and many in between, with no success.

Only option that worked almost everytime was this: js/build.sh embed, but it always ends up giving me .wasm file, and a .js file that has dependency of it.

After 5+ hours of tinkering and trial&error I decided to ask for help.

There might be something I'm missing, because I'm not that familiar with python/C++ etc.

At this point I would like to get it working with Node, but ofc it would be nice to see also how it would work on browser too.

I was testing this on Ubuntu 20.04 if that helps.

EDIT: I figured out that it's supposed to give .wasm nowadays, but it can be emitted by updating js/build.sh with a flag -sWASM=0.

EDIT2: Here is a working example, with AND without wasm, but it seems to give me Promises now. Not sure if this has something to do with the rather new version of emscripten or something else.

hatapitk commented 10 months ago

Thanks for the report! I will look into this at some point. Emscripten changes very often, the last time I needed to fix things was 9 months ago. But I have to check that Wiki page, it might be outdated.

hatapitk commented 9 months ago

I found out that the latest version requires few more exported functions that I have now added. Tested in the browser for now. Please reopen if it still does not work for you.