Closed pimpale closed 3 years ago
Thanks for highlighting the issue. We had not imagined this use case!
You are right the load time difference is not noticeable — we did a quick measurement and it takes about 30ms to 40ms more on a 2.2 GHz 6-Core Intel Core i7/16GB machine; on mobile device it may go up to 100-200ms more, which should also be acceptable.
Will fix the issue shortly and release a new patch.
Released version 1.2.2 with the above patch.
Thanks!
Creating a second instance of the nlp object fails with the following error:
Uncaught TypeError: clusters[k].split is not a function
Example of code causing the problem:
Here is a demonstration of this behavior: https://codepen.io/pimpale-the-sans/pen/RwVyeGX
My use case for having multiple nlp objects is to to learn different custom entities on each one.
The source of the problem is
wink-eng-lite-web-model/dist/read-core-model.js
:This file modifies a global variable, which means that subsequent loads of the model will fail, since the data is no longer in the correct form.
Here is a working solution that prevents this:
This code snippet copies the model before changing it. I tested this version, and it seems to solve the error. It also did not noticeably slow down loading the model.