From 96c572d67ea44242a34be4dae359c35677b25098 Mon Sep 17 00:00:00 2001 From: ab Date: Wed, 30 Oct 2019 16:52:16 -0400 Subject: ibm server request works! --- src/client/apis/IBM_Recommender.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/client/apis/IBM_Recommender.ts (limited to 'src/client/apis') diff --git a/src/client/apis/IBM_Recommender.ts b/src/client/apis/IBM_Recommender.ts new file mode 100644 index 000000000..4043342f4 --- /dev/null +++ b/src/client/apis/IBM_Recommender.ts @@ -0,0 +1,38 @@ +import { Opt } from "../../new_fields/Doc"; + +const NaturalLanguageUnderstandingV1 = require('ibm-watson/natural-language-understanding/v1'); +const { IamAuthenticator } = require('ibm-watson/auth'); + +export namespace IBM_Recommender { + + const naturalLanguageUnderstanding = new NaturalLanguageUnderstandingV1({ + version: '2019-07-12', + authenticator: new IamAuthenticator({ + apikey: 'tLiYwbRim3CnBcCO4phubpf-zEiGcub1uh0V-sD9OKhw', + }), + url: 'https://gateway-wdc.watsonplatform.net/natural-language-understanding/api' + }); + + const analyzeParams = { + 'url': 'www.ibm.com', + 'features': { + 'keywords': { + 'sentiment': true, + 'emotion': true, + 'limit': 3 + } + } + }; + + export const analyze = async (_parameters: any): Promise> => { + try { + const response = await naturalLanguageUnderstanding.analyze(analyzeParams); + console.log(response); + return (JSON.stringify(response, null, 2)); + } catch (err) { + console.log('error: ', err); + return undefined; + } + }; + +} \ No newline at end of file -- cgit v1.2.3-70-g09d2