Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from cloudguy-pro/master
Spellcheck middleware added to JS repo
- Loading branch information
Showing
12 changed files
with
1,646 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.