{"_id":"@botbuildercommunity/middleware-watson-nlu","_rev":"6-0687e093000ddd80b4c8a0ac1318ab94","name":"@botbuildercommunity/middleware-watson-nlu","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@botbuildercommunity/middleware-watson-nlu","version":"1.0.0","description":"Bot Framework middleware component for the IBM Watson NLU service.","main":"./lib/index.js","typings":"./lib/index.d.ts","directories":{"lib":"lib"},"scripts":{"build":"tsc","test":"tsc && mocha","test-ci":"tsc && mocha --reporter xunit --reporter-options output=./test-results.xml --reporter-options suiteName=$npm_package_name"},"repository":{"type":"git","url":"git+https://github.com/BotBuilderCommunity/botbuilder-community-js.git"},"keywords":["chatbots","bot framework","bot builder","emotion analysis","ibm","watson"],"contributors":[{"name":"Bot Builder Community"},{"name":"Michael Szul","email":"michael@szul.us"}],"license":"MIT","bugs":{"url":"https://github.com/BotBuilderCommunity/botbuilder-community-js/issues"},"homepage":"https://github.com/BotBuilderCommunity/botbuilder-community-js#readme","dependencies":{"@botbuildercommunity/middleware-engine-core":"^1.0.0","botbuilder":"^4.5.3","ibm-watson":"^4.3.3"},"devDependencies":{"mocha":"^6.1.4","typescript":"^3.5.2"},"_id":"@botbuildercommunity/middleware-watson-nlu@1.0.0","_nodeVersion":"10.16.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-9QkryPvX396MkeKs4D1A6INu2BrFpE0eSozEwLGMMKtRMbTRL1+Z3jVQyGySvU2sYWjOwKAkEADQWrUzvOHwPg==","shasum":"efdbba61c8e023da10ffc53c575467a38e45405c","tarball":"https://registry.npmjs.org/@botbuildercommunity/middleware-watson-nlu/-/middleware-watson-nlu-1.0.0.tgz","fileCount":37,"unpackedSize":49589,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdTzDRCRA9TVsSAnZWagAAUJUP/iQ1lyhJcEyB/DToTr+O\n5depPO+BNmsbrnl9NqTNCoxRdUIUeIUH+eULkCd4tpKGBqL204mgTOWwY0Ez\n+++N6OYuXZwRXJnyoVhGrJcH9JJlpctHF8fF3E/ZxTyxAANgDkOJBwSuMFoR\n4QqYmNYI7ULdLUy4mue88Oc1BYqK+1uIFx0Z/2uku6IzT1Z0GBBW8NlGOpTQ\nvEzoweSiotITkvDisICfquX+h0H7GgMmIYXryfw12HkEC/MdK/UK8epEbdT0\n7Jh3YxuMPUs3oLAIH13ay5WYNMqY5/q/h5NGFlnBDsrmCAS9D7EaNzh+j1K9\nXlCNEyEeljG1FaqoxBvEqI+7+ndafDV1lkey1OVnezDykDrtyhilqHTMl8c2\nfACNSVrzTFA8jSycDDOk/Zh/LZkaB9Ps8h3uGZjyPBG2F2AIY9ruo6Tv92Ec\nfDxG+gdVt7AQrW0oBWvnp58eS7SSPZ2JMs+J2jvse67XRuwauL3oDz3UEbkH\nIjCoLef/AizXEVhj12PSAyC1i3+u50JSMurWttj4jgyCrwfy2wNFfp2tkLZ8\n4jyVaYm5m1u2o95SOg7Ib+DgDNfuGqhzOFGv6PNx2YfSzj7vE24di+yW9J1V\nsiAFQC19nDWZgzVKrVzB2fmTedLP2DB25QBkI11GLuvzq0N+0nyeg9Ks+MI0\nsUrG\r\n=lOot\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDGfuw6AKj2jW0znlDcJ8v1xzdL8zC40uwdvi5q1AajEQIgU8Q0nSc6eIsK3kTc+JL37eysGFJfAT9pUhYoB8w+2oY="}]},"maintainers":[{"name":"cloudguy_pro","email":"stephan@bisser.at"},{"name":"szul","email":"michael@szul.us"},{"name":"jamesemann","email":"james.mann@bcs.org"}],"_npmUser":{"name":"szul","email":"michael@szul.us"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/middleware-watson-nlu_1.0.0_1565470929075_0.4184222268389839"},"_hasShrinkwrap":false},"1.0.1":{"name":"@botbuildercommunity/middleware-watson-nlu","version":"1.0.1","description":"Bot Framework middleware component for the IBM Watson NLU service.","main":"./lib/index.js","typings":"./lib/index.d.ts","directories":{"lib":"lib"},"scripts":{"build":"tsc","test":"tsc && mocha","test-ci":"tsc && mocha --reporter xunit --reporter-options output=./test-results.xml --reporter-options suiteName=$npm_package_name"},"repository":{"type":"git","url":"git+https://github.com/BotBuilderCommunity/botbuilder-community-js.git"},"keywords":["chatbots","bot framework","bot builder","emotion analysis","ibm","watson"],"contributors":[{"name":"Bot Builder Community"},{"name":"Michael Szul","email":"michael@szul.us"}],"license":"MIT","bugs":{"url":"https://github.com/BotBuilderCommunity/botbuilder-community-js/issues"},"homepage":"https://github.com/BotBuilderCommunity/botbuilder-community-js#readme","dependencies":{"@botbuildercommunity/middleware-engine-core":"^1.0.0","botbuilder":"^4.5.3","ibm-watson":"^4.3.3"},"devDependencies":{"mocha":"^6.1.4","typescript":"^3.5.2"},"_id":"@botbuildercommunity/middleware-watson-nlu@1.0.1","_nodeVersion":"10.16.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-w/vh2NOjY3oqM0MoVg53zaY6UukVGelBeHyTa7QVixvrhHBIfubmTYGNtQLnlO9+Wm5neUK9uZLQAgL5hPG48Q==","shasum":"1b446fc33ab3167cf6b9c529fedf45ab72d50b0c","tarball":"https://registry.npmjs.org/@botbuildercommunity/middleware-watson-nlu/-/middleware-watson-nlu-1.0.1.tgz","fileCount":39,"unpackedSize":44117,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdc6QQCRA9TVsSAnZWagAA3yEP+wcQxltW57tHXRzpaGcq\ntn53ZcN6ScMMt024ZId2otuEx8jvV9R0yjvzismQb3QINLOLFLvIuHwa+wdA\nuIoH+wf2KDMhu2/NSULMpoE3LB1gjmtQ8y7tJClmWpfopz8VShpHauNwsil9\ni7L22PKmlPO6z/S4R7o4HgOz+22tlwI9oU0SRdl8Q3FOnS9Pw/zKmBpyznL9\nmR6CvRURuGY4T7dv9C6m4IA5nFdFtKSaoNLYSVDpbSRz/LGqBWPaFM6Qqsro\nskto/W97EHcZydCsv6Vmv1v4HrmdscA4M1g2dXWvXoZ5oT8YZrG2tMF8weT6\nanU3m9UTkAQ0Rqd4f0b1QLNy+zmWeGM5QObM1QdL/oTSw44XH2aIug0AnU5C\nj+XX14yhASi/SXnDLSig/6eBbTEi9x4pazXRhnpKLk66l5xbZ4Xhg+FHqZnT\nGY5yf1BPHlmcb4V7tG+uLS7hcVhQI/2S5vYFUfNvYRijgbrGy45iSbi5etZt\nybj9BiObpD7eZdCh21omsdYGmXxq0zzJepvmxGBlFyO5hIrN+ZcQpra7yX/X\nZH7VtOJQ8fqqA1HPtMTyo5RmLjLNUctxxQuzYRPoGrmChtMfjFLj85axxHPA\nkvEZ2280Favzzv9IcQR2/IO7YEcsKyEa9s3No19UeT9kH2PlQRfpxD0ETZkl\nHU8i\r\n=ufFl\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDmvVKx61EPDNO02Ssfh5lENbraLtCs5v96HYhaA7M8UAIhAJqdynN3rwWQegFH6Zi2uf77ZgHa5xp0mWA+IixcMVBH"}]},"maintainers":[{"name":"cloudguy_pro","email":"stephan@bisser.at"},{"name":"jamesemann","email":"james.mann@bcs.org"},{"name":"szul","email":"michael@szul.us"}],"_npmUser":{"name":"szul","email":"michael@szul.us"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/middleware-watson-nlu_1.0.1_1567859727335_0.29786798331388487"},"_hasShrinkwrap":false},"1.1.0":{"name":"@botbuildercommunity/middleware-watson-nlu","version":"1.1.0","description":"Bot Framework middleware component for the IBM Watson NLU service.","main":"./lib/index.js","typings":"./lib/index.d.ts","directories":{"lib":"lib"},"scripts":{"build":"tsc","test":"tsc && mocha","test-ci":"tsc && mocha --reporter xunit --reporter-options output=./test-results.xml --reporter-options suiteName=$npm_package_name"},"repository":{"type":"git","url":"git+https://github.com/BotBuilderCommunity/botbuilder-community-js.git"},"keywords":["chatbots","bot framework","bot builder","emotion analysis","ibm","watson"],"contributors":[{"name":"Bot Builder Community"},{"name":"Michael Szul","email":"michael@szul.us"}],"license":"MIT","bugs":{"url":"https://github.com/BotBuilderCommunity/botbuilder-community-js/issues"},"homepage":"https://github.com/BotBuilderCommunity/botbuilder-community-js#readme","dependencies":{"@botbuildercommunity/middleware-engine-core":"^1.1.0","botbuilder":"^4.5.3","ibm-watson":"^4.3.3","mathjs":"^6.2.2"},"devDependencies":{"@types/mathjs":"^6.0.2","mocha":"^6.1.4","typescript":"^3.5.2"},"_id":"@botbuildercommunity/middleware-watson-nlu@1.1.0","_nodeVersion":"10.16.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-hjBEFPuq+eYu7ZKvCBQrSa1NsFlzm1PwJxzzw1TNfeY0l4fhDBVCy3elSAmtV0F0NMMI+QPffK6pt5EH/qiOcw==","shasum":"0b454183d5a9c8429abc10e83ce16e150f199b2b","tarball":"https://registry.npmjs.org/@botbuildercommunity/middleware-watson-nlu/-/middleware-watson-nlu-1.1.0.tgz","fileCount":40,"unpackedSize":74643,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdliLqCRA9TVsSAnZWagAAbawP/3cAaN/kEG8D6GZDtDYB\n+qWdShYy5ELY0Q7lLZQRlo2mKbEWNfHw5ZN8p3auSoN7tqPKAkIJFDCrpGMz\nTTpNZFB0aPxfKfJlRbRjsRivgGVXMr0xtwO1TR7SEuNmvEMf/z8TJ4JfObiO\ncmst2rdwJ7rVJiHyO02vaSahKSjQCRX00p3U645rONTwXkZuBBx1qLT+yLa2\nRLj8bZbdh/MD3SiZDlNkIo70a1IQ58rlbtxaN223CXVZSRvCsLn19wJXbovA\nC0MvABbamWpTBkc8Aos5Zb6ekCQuy3D8ep9rZYHmEBE6ivLOaMIw3MO01HTn\nztz1UkX0VJOKP8vEdzAx4clOVEKre+TPuk2YqE639X1Au4rGKMTCQVV13kkL\nDRa9ol3iv6593//NeKQIZ2+wlZc5d6EVNbltun7u0u9zyAZPT/PpccbkzXPD\nTUrtPyY2UIahE4vbRsgVNmBpiqgZAV3EfpCuGccH/f0+HxnKR8Oo3UaTKhpz\nXRF3FFtOJFk0fZp/kiitIsK28Ws+z4cF2lyb7p63juepcirBzcxCdrD1XL1g\nW/lMrHHxE3KetGJPkWBeM56FPfMowvSXleXCU5erFpe+sWekgLEiXDrzStr+\ncIPQUqdd6bAbUN1Wtn2B6bKMnMdiGe/5O2v9RqiRKajvuwbpqN8jQ47DPWzb\nA/A2\r\n=Ur2c\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEZmiKwn68ZoqZlcoBen31kcXp41jZkveYn+Oph5v+44AiEA/Hih59zrF1QrPsjw2hO9VKato6P7WJP66kbhlPYUwMU="}]},"maintainers":[{"name":"cloudguy_pro","email":"stephan@bisser.at"},{"name":"jamesemann","email":"james.mann@bcs.org"},{"name":"szul","email":"michael@szul.us"}],"_npmUser":{"name":"szul","email":"michael@szul.us"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/middleware-watson-nlu_1.1.0_1570120425383_0.7569449924391178"},"_hasShrinkwrap":false},"1.1.1":{"name":"@botbuildercommunity/middleware-watson-nlu","version":"1.1.1","description":"Bot Framework middleware component for the IBM Watson NLU service.","main":"./lib/index.js","typings":"./lib/index.d.ts","directories":{"lib":"lib"},"nyc":{"extends":"@istanbuljs/nyc-config-typescript","all":true,"check-coverage":true,"lines":0,"statements":0,"functions":0,"branches":0,"exclude":["**/*.d.ts","**/*.test.js"],"reporter":["text","cobertura","html"],"report-dir":"./.nyc_output/coverage"},"scripts":{"build":"tsc","test":"tsc && nyc mocha","test-ci":"tsc && nyc mocha --reporter xunit --reporter-options output=./test-results.xml --reporter-options suiteName=$npm_package_name"},"repository":{"type":"git","url":"git+https://github.com/BotBuilderCommunity/botbuilder-community-js.git"},"keywords":["chatbots","bot framework","bot builder","emotion analysis","ibm","watson"],"contributors":[{"name":"Bot Builder Community"},{"name":"Michael Szul","email":"michael@szul.us"}],"license":"MIT","bugs":{"url":"https://github.com/BotBuilderCommunity/botbuilder-community-js/issues"},"homepage":"https://github.com/BotBuilderCommunity/botbuilder-community-js#readme","dependencies":{"@botbuildercommunity/middleware-engine-core":"^1.1.0","botbuilder":"^4.8.0","ibm-watson":"^4.3.3","mathjs":"^6.2.2"},"devDependencies":{"@istanbuljs/nyc-config-typescript":"^0.1.3","@types/mathjs":"^6.0.2","mocha":"^7.1.1","nyc":"^15.0.0","typescript":"^3.5.2"},"publishConfig":{"access":"public"},"gitHead":"1066f5f7752f3298e575aa495afa4592d5f54a44","_id":"@botbuildercommunity/middleware-watson-nlu@1.1.1","_nodeVersion":"12.14.0","_npmVersion":"lerna/3.20.2/node@v12.14.0+x64 (darwin)","dist":{"integrity":"sha512-MQVLMz/Ini362ch0r1RW+Vhp+x0vVYPGyOkGVvr2WkDOJRxfAnXceUKR+CY05Oa5hBBcvICemg75m/ubAYqUZg==","shasum":"b3e44e97fc96d37c85fb8436191e2c75143f0a26","tarball":"https://registry.npmjs.org/@botbuildercommunity/middleware-watson-nlu/-/middleware-watson-nlu-1.1.1.tgz","fileCount":64,"unpackedSize":380368,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefMsXCRA9TVsSAnZWagAAEgwP/ijHDWpVrXi/UjeDNg78\nQ13w0Jr1mzcJ4+fZp0F9NTknNvswwzgl5MKl+JGs3yJsy4jikuWCM8Pks+C2\n1Hr/v5Qz0hDqjpsGCuJe8tKE/q4UmpQiM1h7rjlHBp7qg+m9hrY3ugHGAW4Y\n9QGWic86NnbJWsTGoIFb28h5yJF8KlEw1HfTU7q/iR4bAkjcuVjDVPiTXjMh\nm6PWuD+r92kQK+Y1MDZ+xX8YwsdOL7zJ1UO0GccNZo6F3z6I7qi9B0p/AXcS\nbFgVLEfrhWtqn8rSxwGNA4GHsg8Kjk8ZRaXVthO7IEdKbUx7aA5/vZ/ei68d\nCb/Unk3Hsh9+0knqsBJ2tCjuJdj9MhpLxWkBWUKu5jThOrTF0i8UN3QbktW6\n/ciNTy7zX+tf8wqwg1DX/exzhfwOF1yVj936h3GYD3tS2BjyrWDlvQne+Ze1\nmqerU45PfJaPfOnc3c052Zyge+br/RE1/g23VcYxJ215hCfnZLRzuYhTaNGE\nJPunJPBZTwgxzrE6mTXF13UcfciJ/Z4Pw8g+ZpyOZMFe6Jqrv6D6u3z8Eq6O\nAbFbzvjeoDH7BcbPNvomLu1abnc3RoBi4TpJvk6SglOnrOBg1Ra2K48HCDeC\n0NoFR86sct4dL3khaWBLApa4tKLYCB38ZI1iFTANkrcOLe5EpxR8Bgdpb2Cw\nrfYX\r\n=nH9R\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBPFYeXtqU6/JZJ6kt8tmJpNWsx1+0rJIyjYs87kERWwAiEAkunmT8Nf5E07qk8ChFuLpsIXiMxVZU5DKglgP2YS6AM="}]},"maintainers":[{"email":"stephan@bisser.at","name":"cloudguy_pro"},{"email":"mick@imick.nl","name":"imick"},{"email":"james.mann@bcs.org","name":"jamesemann"},{"email":"michael@szul.us","name":"szul"}],"_npmUser":{"name":"imick","email":"mick@imick.nl"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/middleware-watson-nlu_1.1.1_1585236758807_0.16865627702165353"},"_hasShrinkwrap":false}},"time":{"created":"2019-08-10T21:02:08.977Z","1.0.0":"2019-08-10T21:02:09.245Z","modified":"2022-04-04T20:13:43.486Z","1.0.1":"2019-09-07T12:35:27.564Z","1.1.0":"2019-10-03T16:33:45.511Z","1.1.1":"2020-03-26T15:32:38.958Z"},"maintainers":[{"email":"james.mann@bcs.org","name":"jamesemann"},{"email":"stephan@bisser.at","name":"cloudguy_pro"},{"email":"mick@imick.nl","name":"imick"}],"description":"Bot Framework middleware component for the IBM Watson NLU service.","homepage":"https://github.com/BotBuilderCommunity/botbuilder-community-js#readme","keywords":["chatbots","bot framework","bot builder","emotion analysis","ibm","watson"],"repository":{"type":"git","url":"git+https://github.com/BotBuilderCommunity/botbuilder-community-js.git"},"contributors":[{"name":"Bot Builder Community"},{"name":"Michael Szul","email":"michael@szul.us"}],"bugs":{"url":"https://github.com/BotBuilderCommunity/botbuilder-community-js/issues"},"license":"MIT","readme":"# Watson NLU Middleware\n\nThe Watson NLU Middleware offers Bot Framework middleware components for the IBM Watson NLU API. You will need an IBM Cloud account. Take a look at the [IBM Watson NLU API documentation](https://www.ibm.com/watson/services/natural-language-understanding/) for details.\n\n## Installing\n\n    npm install @botbuildercommunity/middleware-watson-nlu --save\n\n## Usage\n\nAll middleware is created and used in the same way. For example, for emotion detection, import the `EmotionDetection` class from the package, and add it to your bot adapter:\n\n```typescript\nimport { EmotionDetection } from '@botbuildercommunity/middleware-watson-nlu';\n\nadapter.use(new EmotionDetection(WATSON_API_KEY, WATSON_ENDPOINT, WATSON_OPTIONS));\n```\n\nThe `WATSON_OPTIONS` parameter is optional.\n\nWhen used, the `turnState` on the `TurnContext` will have a property named `emotionDetection`, which is an object containing emotions as properties, with scores as their values. An example can be seen in the [`sample`](../../samples/middleware-watson-nlu/index.js) bot test file.\n\nSupported middleware classes include:\n\n* `CategoryExtraction`\n* `ConceptExtraction`\n* `EmotionDetection`\n* `EntityExtraction`\n* `KeyPhrases`\n* `SentimentAnalysis`\n\nEach class takes the two required parameters in the example usage above (with the WATSON_OPTIONS parameter being optional).\n\nIn each case, properties are added to the `turnState` of the `TurnContext`. You can retrieve them in your bot via:\n\n* `context.turnState.get('categoryEntities')`\n* `context.turnState.get('conceptEntities')`\n* `context.turnState.get('emotionDetection')`\n* `context.turnState.get('textEntities')`\n* `context.turnState.get('keyPhrases')`\n* `context.turnState.get('sentimentScore')`\n\n### Emotion Detection\n\nThe package includes additional helper functionality for emotion detection to speed your bot development.\n\n#### Setting Targets\n\nWatson's NLU allows you to set specific target keywords for emotional analysis. You can do this by setting a configuration value for targets to a string array:\n\n```typescript\nimport { EmotionDetection } from '@botbuildercommunity/middleware-watson-nlu';\n\nconst emotionDetection = new EmotionDetection(WATSON_API_KEY, WATSON_ENDPOINT, WATSON_OPTIONS);\nemotionDetection.set('targets', ['mercury', 'venus', 'mars']);\n\nadapter.use(emotionDetection);\n```\n\n> Note that as of this release of Watson's NLU component, setting targets _expects_ one of those targets to be present, and will throw an exception otherwise.\n\nIf you set targets, you can access the emotion objects for each of those targets off of the array that gets set in the `TurnState`:\n\n```typescript\nconst targets = context.turnState.get('emotionTargets');\n```\n\nIn the above code snippet, `targets` is an array of objects containing the target names and an emotion object per target. It may look something like this:\n\n```typescript\n[\n    {\n        text: 'venus',\n        emotion: {\n            sadness: 0.044599,\n            joy: 0.779204,\n            fear: 0.020602,\n            disgust: 0.016107,\n            anger: 0.020998\n        }\n    },\n    {\n        text: 'mars',\n        emotion: {\n            sadness: 0.044599,\n            joy: 0.779204,\n            fear: 0.020602,\n            disgust: 0.016107,\n            anger: 0.020998\n        }\n    }\n]\n```\n\n#### Setting the Document\n\nYou can also choose to turn off document level analysis by setting the document configuration property to `false`.\n\n```typescript\nimport { EmotionDetection } from '@botbuildercommunity/middleware-watson-nlu';\n\nconst emotionDetection = new EmotionDetection(WATSON_API_KEY, WATSON_ENDPOINT, WATSON_OPTIONS);\nemotionDetection.set('document', false);\nemotionDetection.set('targets', ['mercury', 'venus', 'mars']);\n\nadapter.use(emotionDetection);\n```\n\n#### Static Helper Methods\n\nSince emotion detection returns an object of key/value pairs, we've built a handful of static helper methods off of the `EmotionDetection` class to better enable you to parse and rank results.\n\n* `getEmotions(result: nlup.EntitiesResult | nlup.KeywordsResult): nlup.EmotionScores`\n\nTakes either an `EntitiesResult` or `KeywordsResult` object returned from Watson's NLU and returns an `EmotionScores` object.\n\n* `rankEmotionKeys(emotionScores: nlup.EmotionScores): string[]`\n\nTakes an `EmotionScores` objects and returns a string array of the emotion keys (i.e., names of the emotions) in order of relevance.\n\n* `rankEmotions(emotionScores: nlup.EmotionScores): Emotion[]`\n\nTakes an `EmotionScores` objects and returns a `Emotion` array in order of relevance. The `Emotion` object is an object with a `name` and `score` property.\n\n* `topEmotion(emotionScores: nlup.EmotionScores): string`\n\nTakes an `EmotionScores` object and returns the name of the emotion that is most relevant.\n\n* `topEmotionScore(emotionScores: nlup.EmotionScores): Emotion`\n\nTakes an `EmotionScores` object and returns an `Emotion` object representing the most relevant emotion.\n\n* `calculateDifference(emotionScores: nlup.EmotionScores, firstEmotion?: string, secondEmotion?: string): number`\n\nIf called with only the `EmotionScores` object, will return the difference between the top two emotions. If the other two parameters are provided, it'll return the difference between the two specified.\n\n* `calculateVariance(emotionScores: nlup.EmotionScores): number`\n\nTakes an `EmotionScores` object and returns the variance between all emotion scores.\n\n##### Usage\n\nSince these are static methods, you call them directly off of the `EmotionDetection` class. For example:\n\n```typescript\nconst emotion: string = EmotionDetection.topEmotion(EMOTIONSCORES_OBJECT);\n```\n\n### Entity Extraction\n\nThe package includes additional helper functionality for entity extraction to speed your bot development.\n\n#### Setting Emotions and Sentiment\n\nWatson's NLU allows you to specify boolean values to turn on emotion detection and sentiment analysis for individual entities. You can set these configuration values using the `set()` method on the middleware:\n\n```typescript\nimport { EntityExtraction } from '@botbuildercommunity/middleware-watson-nlu';\n\nconst entityExtraction = new EntityExtraction(WATSON_API_KEY, WATSON_ENDPOINT, WATSON_OPTIONS);\nentityExtraction.set('emotion', true);\nentityExtraction.set('sentiment', true);\n\nadapter.use(entityExtraction);\n```\n\n#### Static Helper Methods\n\nWe've built a handful of static helper methods off of the `EntityExtraction` class to better enable you to parse and rank results.\n\n* `getEntities(entitiesResult: nlup.EntitiesResult[], type?: string): string[]`\n\nTakes an array of `EntitiesResult` and returns an array of strings which are the text entities that have been extracted.\n\n* `rankEntityKeys(entitiesResult: nlup.EntitiesResult[], ranking: RANKING = RANKING.RELEVANCE): string[]`\n\nTakes an array of `EntitiesResult` objects and an option ranking choice (either relevance or confidence) and returns a string array of the entities in order of ranking.\n\n* `rankEntities(entitiesResult: nlup.EntitiesResult[], ranking: RANKING = RANKING.RELEVANCE): nlup.EntitiesResult[]`\n\nTakes an array of `EntitiesResult` objects and returns an ordered array of `EntitiesResult` objects. As above, your ranking can be either according to relevance or confidence.\n\n* `topEntity(entitiesResult: nlup.EntitiesResult[], ranking: RANKING = RANKING.RELEVANCE): string`\n\nTakes an array of `EntitiesResult` objects and an optional ranking and returns the text of the entity ranked the highest.\n\n* `topEntityResult(entitiesResult: nlup.EntitiesResult[], ranking: RANKING = RANKING.RELEVANCE): nlup.EntitiesResult`\n\nTakes an array of `EntitiesResult` objects and an optional ranking and returns an `EntitiesResult` object representing the highest ranking item.\n\n##### Usage\n\nSince these are static methods, you call them directly off of the `EntityExtraction` class. For example:\n\n```typescript\nconst entity: string = EntityExtraction.topEntity(ENTITYRESULT_OBJECT);\n```\n\n### Keywords/Key Phrases\n\nThe package includes additional helper functionality for handling key phrases to speed your bot development.\n\n#### Setting Emotions and Sentiment\n\nWatson's NLU allows you to specify boolean values to turn on emotion detection and sentiment analysis for individual keywords and phrases. You can set these configuration values using the `set()` method on the middleware:\n\n```typescript\nimport { KeyPhrases } from '@botbuildercommunity/middleware-watson-nlu';\n\nconst keyPhrases = new KeyPhrases(WATSON_API_KEY, WATSON_ENDPOINT, WATSON_OPTIONS);\nkeyPhrases.set('emotion', true);\nkeyPhrases.set('sentiment', true);\n\nadapter.use(keyPhrases);\n```\n\n#### Static Helper Methods\n\nWe've built a handful of static helper methods off of the `KeyPhrases` class to better enable you to parse and rank results.\n\n* `rankKeywordKeys(keywordsResult: nlup.KeywordsResult[]): string[]`\n\nTakes an array of `KeywordsResult` objects and returns a string array of the keywords in order of relevance.\n\n* `rankKeywords(keywordsResult: nlup.KeywordsResult[]): nlup.KeywordsResult[]`\n\nTakes an array of `KeywordsResult` objects and returns an ordered array of `KeywordsResult` objects by relevance.\n\n* `topKeyword(keywordsResult: nlup.KeywordsResult[]): string`\n\nTakes an array of `KeywordsResult` objects and returns the text of the keyword ranked the highest.\n\n* `topKeywordResult(keywordsResult: nlup.KeywordsResult[]): nlup.KeywordsResult`\n\nTakes an array of `KeywordsResult` objects and returns a `KeywordsResult` object representing the highest ranking item.\n\n##### Usage\n\nSince these are static methods, you call them directly off of the `KeywordsResult` class. For example:\n\n```typescript\nconst keyword: string = KeywordsResult.topKeyword(KEYWORDRESULT_OBJECT);\n```\n","readmeFilename":"README.md"}