Skip to content

Commit

Permalink
add getFacet api
Browse files Browse the repository at this point in the history
Allow retrieving text data about facets
  • Loading branch information
soumak77 committed Jul 12, 2017
1 parent b5a802f commit 177918a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 177918a

Please sign in to comment.