Botfuel / botfuel-dialog

Botfuel SDK to build highly conversational chatbots
https://docs.botfuel.io
Other
102 stars 18 forks source link

Improve extractor loading #246

Closed simon-tannai closed 6 years ago

simon-tannai commented 6 years ago

Hello !

I faced a problem on extractors loading from Botfuel NLU. By default, all JS files into extractors directory are loaded, including files containing parent class.

The problem was that a parent class is loaded and executed while his constructor parameters are required. It returned an error.

https://github.com/Botfuel/botfuel-dialog/blob/e185228d11b21a54fd5fe7e32cc50057ef957a5d/packages/botfuel-dialog/src/nlus/botfuel-nlu.js#L74

I think we just have to improve this regex to allow JS files to not be loaded:

return files.filter(file => file.match(/^.*-extractor.js$/));

So, files without -extractor will not be loaded and allow us to create some-parentextractor.js for example.

botfuel-unitobot commented 6 years ago

Hello Simon,

TLDR: there is a short term workaround and we are redesigning entity extraction...

Short term workaround: You can easily design your own NLU module (for example by subclassing botfuel-nlu) and implement yourself what you propose, you just need to redefine: getExtractorFiles(path)

Entity extraction redesign: Too long to be described here but in the future, there won't be any local extractors anymore, thus the problem won't exist anymore.

As a consequence, it is very likely that we won't implement ourselves the fix you proposed.

Yan