Azure / botbuilder-instrumentation

Add extra logging for bot framework
MIT License
23 stars 22 forks source link

Support sentiment analysis in multiple languages #13

Closed iMicknl closed 6 years ago

iMicknl commented 7 years ago

At the moment the sentiment analysis is supported in 15 languages , but botbuilder-instrumentation uses English as hardcoded default.

In think that the right way should be to retrieve the preferredLocale since this should be used to set the language for the current session. However, maybe there should be a setting to override the behaviour via the settings to add a default language?

Only the first two characters are taken from the preferredLocale since the sentiment analysis API only accepts the country code without culture code. (en vs en-us)

iMicknl commented 7 years ago

If anyone has suggestions how to make sure we only query supported languages, let me know. A hardcoded array inside the source doesn't have my preference, but maybe I should add the possibility to pass an array of supported languages via the options?

morsh commented 7 years ago

@iMicknl - I'm guessing one way to go about it, is enable an array of supported languages. If this is supplied you can pass each phrase through language recognizer service and that result (in case in the array) can be passed to the sentiment analysis service

iMicknl commented 7 years ago

@morsh thanks! Performance wise, I don't think the 'Language Detection' API should be enabled by default, since it is an extra API request. If a chatbot uses multiple languages there is a big chance they are already using an API like this. Using session.preferredLocale() by default is the best option in my opinion, with the option to enable the 'Language Detection' via the options.

The 'Language Detection API' is also not very accurate while detecting smaller sentences, however this doesn't matter that much is the result is just used for sentiments analysis.

I will work something out and update this pull request!

iMicknl commented 6 years ago

Sorry, forgot about this and will close it since v4 is already out of preview at the moment.