Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var fs = require('fs');
var NaturalLanguageUnderstandingV1 = require('ibm-watson/natural-language-understanding/v1.js');
require('dotenv').config({ silent: true }); // optional
var nlu = new NaturalLanguageUnderstandingV1({
// note: if unspecified here, credentials are pulled from environment properties:
// NATURAL_LANGUAGE_UNDERSTANDING_USERNAME & NATURAL_LANGUAGE_UNDERSTANDING_PASSWORD
// username: ''.
// password: '',
version: '2018-04-05',
url: 'https://gateway.watsonplatform.net/natural-language-understanding/api/'
});
var filename = '../test/resources/natural_language_understanding/energy-policy.html';
fs.readFile(filename, 'utf-8', function(file_error, file_data) {
if (file_error) {
console.log(file_error);
} else {
var options = {
html: file_data,
features: {
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const express = require('express');
const NaturalLanguageUnderstandingV1 = require('ibm-watson/natural-language-understanding/v1.js');
const { IamAuthenticator } = require('ibm-watson/auth');
const app = express();
// Create the service wrapper
const nlu = new NaturalLanguageUnderstandingV1({
version: '2018-04-05',
authenticator: new IamAuthenticator({
apikey: process.env.NATURAL_LANGUAGE_UNDERSTANDING_IAM_APIKEY || 'type-key-here',
}),
url: process.env.NATURAL_LANGUAGE_UNDERSTANDING_URL,
});
// setup body-parser
const bodyParser = require('body-parser');
app.use(bodyParser.json());
// Bootstrap application settings
require('./config/express')(app);
app.get('/', (req, res) => {
silent: true
});
const express = require('express'); // app server
const bodyParser = require('body-parser'); // parser for post requests
const numeral = require('numeral');
const fs = require('fs'); // file system for loading JSON
const AssistantV1 = require('ibm-watson/assistant/v1');
const DiscoveryV1 = require('ibm-watson/discovery/v1');
const NaturalLanguageUnderstandingV1 = require('ibm-watson/natural-language-understanding/v1.js');
const ToneAnalyzerV3 = require('ibm-watson/tone-analyzer/v3');
const assistant = new AssistantV1({ version: '2019-06-17' });
const discovery = new DiscoveryV1({ version: '2019-04-17' }); // PRE-SDU VERSION!
const nlu = new NaturalLanguageUnderstandingV1({ version: '2019-06-17' });
const toneAnalyzer = new ToneAnalyzerV3({ version: '2019-06-17' });
const bankingServicesIN = require('./banking_services');
const bankingServicesUS = require('./banking_services_us');
const WatsonDiscoverySetup = require('./lib/watson-discovery-setup');
const WatsonAssistantSetup = require('./lib/watson-assistant-setup');
const DEFAULT_NAME = 'watson-banking-chatbot';
const DISCOVERY_ACTION = 'rnr'; // Replaced RnR w/ Discovery but Assistant action is still 'rnr'.
const locale = process.env.LOCALE;
let DISCOVERY_DOCS = [
'./data/discovery/docs/BankFaqRnR-DB-Failure-General.docx',
'./data/discovery/docs/BankFaqRnR-DB-Terms-General.docx',
'./data/discovery/docs/BankFaqRnR-e2eAO-Terms.docx',
'./data/discovery/docs/BankFaqRnR-e2ePL-Terms.docx',
'./data/discovery/docs/BankRnR-OMP-General.docx'
private init(): any {
return new nlup({
version: '2019-07-12',
iam_apikey: this._apikey,
url: this._url
});
}
private async recognize(text: string, type: string): Promise {