axa-group / nlp.js

An NLP library for building bots, with entity extraction, sentiment analysis, automatic language identify, and so more
MIT License
6.22k stars 616 forks source link

Problem with my web app build because of the way @microsoft/recognizers-text-suite is imported in builtin-microsoft.js #1139

Closed khalil-hadrich closed 2 years ago

khalil-hadrich commented 2 years ago

I am currently working on an NLP module on web app which is developed in TS/Angular and I'm using your library for the intended tasks and among these I need to recognize date entities in users inputs, that's why I am using the builtin-microsoft sub-package. However, since the project in TS and not in JS, require imports don't work so for instance when I import builtin-microsoft, I do it this way : import * as builtin from '@nlpjs/builtin-microsoft';

And in this module you use this package @microsoft/recognizers-text-suite, however to import you use a require import, and for this reason, Recognizers are not correctly imported in my project and date recognizers don't work when I build and test the app. Indeed, the object Recognizers comes in empty with no attributes/methods... Is it possible to change this require import into an import as mentioned before so that the sub-package would work for wider variety of frameworks including TS/Angular.

In addition to that, this is the only import which doesn't work even if there are other require imports. in other sub-packages Indeed most of other imports come from other subfolders of the library which isn't problematic because, in this case the import seems to occur before the project is built in a way where the sub-package containing this require import is imported as hole whereas in the case where the require import is done from an external package such as @microsoft, the import of the external package is done during build time and that is what introduces the problem.

If it's impossible, do you have any alternatives for this sub-package in your library for date extraction purposes ? And/or can you send me some examples of use of builtin-microsoft or the alternative to it so that I can try to use those examples in order to fix my problem ?

Thank you in advance for your response.

NB : I really need to use your library, I'm working on an app which supports 10 languages (Chinese, French, Japanese, English, Spanish, Italian, Portuguese, German, Korean and Russian) and your library is one of the only libraries which take into account as much languages.

jesus-seijas-sp commented 2 years ago

Use the builtin-compromise library instead: https://github.com/axa-group/nlp.js/tree/master/packages/builtin-compromise

Example of how to use in web (in the example the builtin-default, that is the fastest, is used, but you can change it with compromise as it will also works in web). https://github.com/axa-group/nlp.js/issues/843

khalil-hadrich commented 2 years ago

Thank you for your answer. However builtin-compromise can only be used for English and I really need to be able to support at least the non asian languages which I mentioned in the previous comment : Chinese, French, Japanese, English, Spanish, Italian, Portuguese, German, Korean and Russian That's why builtin-microsoft is much more suitable for my case.

jesus-seijas-sp commented 2 years ago

Then I have several bad news for you:

  1. @microsoft/recognizers-text-suite is not prepared for browser
  2. Las version published was 2 years ago, it seems that Microsoft is not actively maintaining the javascript version of the library
  3. The performance of @microsoft/recognizers-text-suite is terrible, as it runs with very complex regular expressions
  4. The size of the bundle of @microsoft/recognizers-text-suite is too big, not recommendable for a web.

My suggestion: build your own builtin library for your needs, based on the builtin-default

khalil-hadrich commented 2 years ago

Thank you very much for these precious suggestions.