From 177918a667f0b7a68896d2b831640b6f1257d327 Mon Sep 17 00:00:00 2001 From: Brian Soumakian Date: Wed, 12 Jul 2017 15:41:14 -0700 Subject: [PATCH] add getFacet api Allow retrieving text data about facets --- README.md | 15 +++++++++++++-- src/index.js | 9 +++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3689a13..8e3f2f3 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,25 @@ $ npm install personality-text-summary ```JavaScript var PersonalityTextSummaries = require('personality-text-summary'); - // locale is one of {'en', 'es', 'ja'}. version refers to which version of Watson Personality Insights to use, v2 or v3. + // locale is one of {'en', 'es', 'ja', 'ko'}. version refers to which version of Watson Personality Insights to use, v2 or v3. var v3EnglishTextSummaries = new PersonalityTextSummaries({ locale: 'en', version: 'v3' }); // retrieve the summary for a specified personality profile (json) var textSummary = v3EnglishTextSummaries.getSummary(myV3EnPersonalityProfile); console.log('The summary for the provided profile is ' + textSummary); +``` - ``` +A few helper methods also exist to get additional text information: +```javascript + var facet = v3EnglishTextSummaries.getFacet('facet_intellect'); + /* + "LowTerm": "Concrete", + "HighDescription": "You are open to and intrigued by new ideas and love to explore them", + "HighTerm": "Philosophical", + "LowDescription": "You prefer dealing with the world as it is, rarely considering abstract ideas", + "Big5": "big5_openness" + */ +``` ## License diff --git a/src/index.js b/src/index.js index c236170..798f887 100644 --- a/src/index.js +++ b/src/index.js @@ -346,6 +346,15 @@ class TextSummary { }; } + getFacet(id) { + const facet = this.facetsData[id]; + if (!facet) { + return Object.assign({}, facet); + } else { + return null; + } + } + intervalFor(p) { return Math.min(Math.floor(p * 4), 3); }