diff options
author | eeng5 <eleanor_eng@brown.edu> | 2020-02-09 14:59:57 -0500 |
---|---|---|
committer | eeng5 <eleanor_eng@brown.edu> | 2020-02-09 14:59:57 -0500 |
commit | daa8898f70bd44d2716f1f0d3371a8435a3ff638 (patch) | |
tree | ccb2ea544eeed0413370cdd69e758faec6170690 /src/client/apis/IBM_Recommender.ts | |
parent | 1e36055e3674fe33dd39f6ad79c969531f7b447c (diff) | |
parent | f6179334d6f2942631caa17b7c8ae2531d87c7c4 (diff) |
Merge branch 'pen' of https://github.com/browngraphicslab/Dash-Web into pen
Diffstat (limited to 'src/client/apis/IBM_Recommender.ts')
-rw-r--r-- | src/client/apis/IBM_Recommender.ts | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/client/apis/IBM_Recommender.ts b/src/client/apis/IBM_Recommender.ts new file mode 100644 index 000000000..da6257f28 --- /dev/null +++ b/src/client/apis/IBM_Recommender.ts @@ -0,0 +1,40 @@ +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 { + + // pass to IBM account is Browngfx1 + + 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 = { + 'text': 'this is a test of the keyword extraction feature I am integrating into the program', + 'features': { + 'keywords': { + 'sentiment': true, + 'emotion': true, + 'limit': 3 + }, + } + }; + + export const analyze = async (_parameters: any): Promise<Opt<string>> => { + try { + const response = await naturalLanguageUnderstanding.analyze(_parameters); + console.log(response); + return (JSON.stringify(response, null, 2)); + } catch (err) { + console.log('error: ', err); + return undefined; + } + }; + +}
\ No newline at end of file |