Is it possible to set up a winkModel (using the wink-eng-lite-web-model
) in a Worker?
#68
-
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 20 replies
-
Have you considered requiring the package outside the function? |
Beta Was this translation helpful? Give feedback.
-
Yes, importing at the top of the script gives the same error |
Beta Was this translation helpful? Give feedback.
-
See if this gives you any clue: https://observablehq.com/@winkjs/how-to-run-wink-nlp-on-observable?collection=@winkjs/winknlp-recipes |
Beta Was this translation helpful? Give feedback.
-
In that case simply browserify your worker and it should work: nlp-main.jsconst winkNLP = require( 'wink-nlp' );
const model = require( 'wink-eng-lite-web-model' );
const nlp = winkNLP( model )
onmessage = function ( e ) {
const message = nlp.readDoc(e.data).tokens().out();
console.log(`[From Main (Text)]: ${e.data}`);
postMessage(JSON.stringify(message));
}; The above file should be browserify using following command: browserify nlp-main.js -o nlp.js |
Beta Was this translation helpful? Give feedback.
-
I see, I see. |
Beta Was this translation helpful? Give feedback.
-
We have release a new version of our Hope it helps you further. |
Beta Was this translation helpful? Give feedback.
In that case simply browserify your worker and it should work:
nlp-main.js
The above file should be browserify using following command: