Skip to content

Commit

Permalink
Update CS Bing Spell Check API Key/Endpoint and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
pcostantini committed Jan 19, 2018
1 parent 8f71489 commit 9ea346d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
10 changes: 5 additions & 5 deletions Node/intelligence-LUIS/.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ MICROSOFT_APP_PASSWORD=
# This Url can be obtained by uploading or creating your model from the LUIS portal: https://www.luis.ai/
LUIS_MODEL_URL=

# This is a free trial Microsoft Bing Spell Check key with limited QPS.
# Please subscribe to create your own key and try it out further.
# Subscription URL: https://www.microsoft.com/cognitive-services/en-us/subscriptions?productId=/products/56ec2df6dbe2d91324586008
BING_SPELL_CHECK_API_KEY=8ae90e80bc4346d59c0f07529dadaa4e

# Boolean value to enable correcting the text before processing it
IS_SPELL_CORRECTION_ENABLED=false

# Subscribe to Cognitive Services Bing Spell Check API to obtain a Trial Key.
# Subscription URL: https://azure.microsoft.com/en-us/try/cognitive-services/?api=spellcheck-api
BING_SPELL_CHECK_API_KEY=
BING_SPELL_CHECK_API_ENDPOINT=https://api.cognitive.microsoft.com/bing/v7.0/spellcheck
19 changes: 10 additions & 9 deletions Node/intelligence-LUIS/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ In the LUIS application's dashboard, click the "Publish App" button in the left

### Code Highlights

One of the key problems in human-computer interactions is the ability of the computer to understand what a person wants, and to find the pieces of information that are relevant to their intent. In the LUIS application, you will bundle together the intents and entities that are important to your task. Read more about [Planning an Application](https://docs.microsoft.com/en-us/azure/cognitive-services/LUIS/plan-your-app) in the LUIS Help
One of the key problems in human-computer interactions is the ability of the computer to understand what a person wants, and to find the pieces of information that are relevant to their intent. In the LUIS application, you will bundle together the intents and entities that are important to your task. Read more about [Planning an Application](https://docs.microsoft.com/en-us/azure/cognitive-services/LUIS/plan-your-app) in the LUIS Help

#### Intent Recognizers

Expand Down Expand Up @@ -92,7 +92,7 @@ Another LUIS Model Feature used is Phrase List Features, for instance, the model
![Phrase List Feature](images/highlights-phrase.png)

In our sample, we are using a [waterfall dialog](https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-waterfall) for the hotel search. This is a common pattern that you'll likely use for most of your intent handlers. The way waterfalls work in Bot Builder is the very first step of the waterfall is called when a dialog (or in this case intent handler) is triggered. The step then does some work and continues execution of the waterfall by either calling another dialog (like a built-in prompt) or calling the optional `next()` function passed in. When a dialog is called in a step, any result returned from the dialog will be passed as input to the results parameter for the next step.
In our sample, we are using a [waterfall dialog](https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-waterfall) for the hotel search. This is a common pattern that you'll likely use for most of your intent handlers. The way waterfalls work in Bot Builder is the very first step of the waterfall is called when a dialog (or in this case intent handler) is triggered. The step then does some work and continues execution of the waterfall by either calling another dialog (like a built-in prompt) or calling the optional `next()` function passed in. When a dialog is called in a step, any result returned from the dialog will be passed as input to the results parameter for the next step.

Our bot tries to check if an entity of city or airport type were [matched and forwards it](app.js#L37-L44) to the next step. If that's not the case, the user is [prompted with a destination](app.js#L47). The [next step](app.js#L50) will receive the destination or airport code in the `results` argument.

Expand Down Expand Up @@ -181,11 +181,11 @@ bot.dialog('ShowHotelsReviews', function (session, args) {

If you want to enable spelling correction, set the `IS_SPELL_CORRECTION_ENABLED` key to `true` in the [.env](.env#L14) file.

Microsoft Bing Spell Check API provides a module that allows you to to correct the spelling of the text. Check out the [reference](https://dev.cognitive.microsoft.com/docs/services/56e73033cf5ff80c2008c679/operations/56e73036cf5ff81048ee6727) to know more about the modules available.
Microsoft Bing Spell Check API provides a module that allows you to to correct the spelling of the text. Check out the [reference](https://dev.cognitive.microsoft.com/docs/services/56e73033cf5ff80c2008c679/operations/56e73036cf5ff81048ee6727) to know more about the modules available.

[spell-service.js](spell-service.js) is the core component illustrating how to call the Bing Spell Check RESTful API.

In this sample we added spell correction as a middleware. Check out the middleware in [app.js](app.js#L109-L125).
In this sample we added spell correction as a middleware. Check out the middleware in [app.js](app.js#L109-L126).

````JavaScript
if (process.env.IS_SPELL_CORRECTION_ENABLED === 'true') {
Expand All @@ -194,6 +194,7 @@ if (process.env.IS_SPELL_CORRECTION_ENABLED === 'true') {
spellService
.getCorrectedText(session.message.text)
.then(function (text) {
console.log('Text corrected to "' + text + '"');
session.message.text = text;
next();
})
Expand Down Expand Up @@ -224,11 +225,11 @@ To get more information about how to get started in Bot Builder for Node and LUI
* [Alarm Bot in Node](https://github.com/Microsoft/BotBuilder/tree/master/Node/examples/basics-naturalLanguage)
* [Microsoft Bing Spell Check API](https://www.microsoft.com/cognitive-services/en-us/bing-spell-check-api)

> **Limitations**
> **Limitations**
> The functionality provided by the Bot Framework Activity can be used across many channels. Moreover, some special channel features can be unleashed using the [Message.sourceEvent](https://docs.botframework.com/en-us/node/builder/chat-reference/classes/_botbuilder_d_.message.html#sourceevent) method.
>
>
> The Bot Framework does its best to support the reuse of your Bot in as many channels as you want. However, due to the very nature of some of these channels, some features are not fully portable.
>
>
> The features used in this sample are fully supported in the following channels:
> - Skype
> - Facebook
Expand All @@ -238,10 +239,10 @@ To get more information about how to get started in Bot Builder for Node and LUI
> - Slack
> - GroupMe
> - Telegram
>
>
> They are also supported, with some limitations, in the following channels:
> - Kik
> - Email
>
>
> On the other hand, they are not supported and the sample won't work as expected in the following channel:
> - SMS
1 change: 1 addition & 0 deletions Node/intelligence-LUIS/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ if (process.env.IS_SPELL_CORRECTION_ENABLED === 'true') {
spellService
.getCorrectedText(session.message.text)
.then(function (text) {
console.log('Text corrected to "' + text + '"');
session.message.text = text;
next();
})
Expand Down
2 changes: 1 addition & 1 deletion Node/intelligence-LUIS/spell-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// https://dev.cognitive.microsoft.com/docs/services/56e73033cf5ff80c2008c679/operations/56e73036cf5ff81048ee6727
var request = require('request');

var SPELL_CHECK_API_URL = 'https://api.cognitive.microsoft.com/bing/v5.0/spellcheck/?form=BCSSCK',
var SPELL_CHECK_API_URL = process.env.BING_SPELL_CHECK_API_ENDPOINT;
SPELL_CHECK_API_KEY = process.env.BING_SPELL_CHECK_API_KEY;

/**
Expand Down

0 comments on commit 9ea346d

Please sign in to comment.