diff options
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/ClientRecommender.scss | 2 | ||||
| -rw-r--r-- | src/client/ClientRecommender.tsx | 7 | ||||
| -rw-r--r-- | src/client/apis/IBM_Recommender.ts | 38 |
3 files changed, 44 insertions, 3 deletions
diff --git a/src/client/ClientRecommender.scss b/src/client/ClientRecommender.scss index 49163cdc8..3f9102f15 100644 --- a/src/client/ClientRecommender.scss +++ b/src/client/ClientRecommender.scss @@ -1,4 +1,4 @@ -@import "/views/globalCssVariables.scss"; +// @import "/views/globalCssVariables.scss"; .space{ border: 1px dashed blue; diff --git a/src/client/ClientRecommender.tsx b/src/client/ClientRecommender.tsx index 86b0839dd..90dd240b6 100644 --- a/src/client/ClientRecommender.tsx +++ b/src/client/ClientRecommender.tsx @@ -13,7 +13,7 @@ import { JSXElement } from "babel-types"; import { RichTextField } from "../new_fields/RichTextField"; import { ToPlainText } from "../new_fields/FieldSymbols"; import { listSpec } from "../new_fields/Schema"; -import { IBM_Recommender } from "./apis/IBM_Recommender"; +import { Identified } from "./Network"; export interface RecommenderProps { title: string; @@ -45,7 +45,10 @@ export class ClientRecommender extends React.Component<RecommenderProps> { super(props); if (!ClientRecommender.Instance) ClientRecommender.Instance = this; ClientRecommender.Instance.docVectors = new Set(); - IBM_Recommender.analyze(); + const parameters: any = {}; + Identified.PostToServer("/IBMAnalysis", parameters).then(response => { + console.log("ANALYSIS RESULTS! ", response); + }); //ClientRecommender.Instance.corr_matrix = [[0, 0], [0, 0]]; } 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<Opt<string>> => { + 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 |
