Skip to content

Instantly share code, notes, and snippets.

@michaeldoye
Created March 11, 2020 10:40
Show Gist options
  • Save michaeldoye/6beb002e34c3ce14abf1c00f08862a60 to your computer and use it in GitHub Desktop.
Save michaeldoye/6beb002e34c3ce14abf1c00f08862a60 to your computer and use it in GitHub Desktop.
const NaturalLanguageUnderstandingV1 = require('ibm-watson/natural-language-understanding/v1');
const { IamAuthenticator } = require('ibm-watson/auth');
const fs = require('fs');
const naturalLanguageUnderstanding = new NaturalLanguageUnderstandingV1({
version: '2019-07-12',
authenticator: new IamAuthenticator({
apikey: '[api_key]',
}),
url: '[URL]',
});
const data = fs.readFileSync('text.txt', 'utf8');
const analyzeParams = {
'text': data,
// 'url': 'https://www.glassdoor.co.uk/Location/Mobiquity-Amsterdam-Location-EI_IE403884.0,9_IL.10,19_IC3064478.htm',
'limit_text_characters': 100000,
"return_analyzed_text": true,
'features': {
'emotion': {
'targets': [
'mario',
]
}
},
};
naturalLanguageUnderstanding.analyze(analyzeParams)
.then(analysisResults => {
console.log(JSON.stringify(analysisResults, null, 2));
})
.catch(err => {
console.log('error:', err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment