Skip to content

Commit

Permalink
Merge pull request #29 from cloudguy-pro/master
Browse files Browse the repository at this point in the history
Spellcheck middleware added to JS repo
  • Loading branch information
stephanbisser committed Dec 10, 2018
2 parents 02ebd0e + 91282e6 commit 6594e1d
Show file tree
Hide file tree
Showing 12 changed files with 1,646 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -10,4 +10,5 @@
/libraries/botbuilder-config/ @szul
/libraries/botbuilder-azuretablestorage/ @szul
/libraries/botbuilder-dialog-prompts/ @szul
/libraries/botbuilder-text-analytics-middleware/ @szul
/libraries/botbuilder-text-analytics-middleware/ @szul
/libraries/botbuilder-spell-check-middleware/ @cloudguy-pro
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -19,5 +19,6 @@ The following Bot Framework compatible packages are available to install within
| ---- | ----------- |-------|
| [botbuilder-azuretablestorage](libraries/botbuilder-azurestablestorage/README.md) | Use Azure Table Storage in your bot | ![NPM Version](https://img.shields.io/badge/npm-0.1.1-red.svg) |
| [botbuilder-text-analytics-middleware](libraries/botbuilder-text-analytics-middleware/README.md) | Use Cogntive Services Text Analytics API for sentiment analysis, language detection, key phrases, and entity extraction | ![NPM Version](https://img.shields.io/badge/npm-0.1.2-red.svg) |
| [botbuilder-spell-check-middleware](libraries/botbuilder-spell-check-middleware/README.md) | Use Cogntive Services Spell Check API to detect misspellings and correct these | ![NPM Version](https://img.shields.io/badge/npm-0.1.0-red.svg) |

> The Azure Table Storage package has been deprecated from Microsoft's `botbuilder-js` repository, and is being taken over by the community.
63 changes: 63 additions & 0 deletions libraries/botbuilder-spell-check-middleware/.gitignore
@@ -0,0 +1,63 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

lib/
30 changes: 30 additions & 0 deletions libraries/botbuilder-spell-check-middleware/README.md
@@ -0,0 +1,30 @@
# Spell Check Middleware

The Spell Check Middleware offers Bot Framework middleware components for the Cognitive Services Bing Spell Check API. You will need an Azure account, as well as a Cognitive Services resource created on Azure. Take a look at the [Bing Spell Check API documentation](https://azure.microsoft.com/en-us/services/cognitive-services/spell-check/) for details.

## Installing

npm install @botbuildercommunity/spell-check-middleware --save

## Usage

All middleware is created and use in the same way. For example, for spell check, import the `SpellCheck` class from the package, and add it to your bot adapter:

```typescript
import { SpellCheck } from '@botbuildercommunity/spell-check-middleware';

adapter.use(new SpellCheck(YOUR_BING_SPELL_CHECK_KEY));
```

When used, the `turnState` on the `TurnContext` will have a property named `suggestion` which is the actual suggestion. Furthermore `turnState` will have a property `token` which is the phrase which has been classified by the service to be replaced by the suggestion. A full example can be seen in the [`bot.js`](test/bot.js) bot test file.

Supported middleware classes include:

* `SpellCheck`

Each class takes the one required parameter like in the example usage above.

In each case, properties are added to the `turnState` of the `TurnContext` You can retrieve them in your bot via:

* `context.turnState.get("token")` //This is the token which you could replace by `suggestion`
* `context.turnState.get("suggestion")` //This is the suggestion which the `token` could be replaced with

0 comments on commit 6594e1d

Please sign in to comment.