Skip to content

Commit 36f8e6d

Browse files
committed
Fixes #62 - Personality insights fully abstracted - readme updated
1 parent fc3bc8e commit 36f8e6d

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Use this SDK to build Watson-powered applications in Unity. It comes with a set
1818
* [Tradeoff Analytics](#tradeoff-analytics)
1919
* [Conversation](#conversation)
2020
* [Visual Recognition](#visual-recognition)
21+
* [Personality Insights](#personality-insights)
2122
* [Developing a basic application in one minute](#developing-a-basic-application-in-one-minute)
2223
* [Documentation](#documentation)
2324
* [License](#license)
@@ -712,6 +713,70 @@ private void OnRecognizeText(TextRecogTopLevelMultiple multipleImages)
712713
}
713714
}
714715
```
716+
### Personality Insights
717+
The IBM Watson™ [Personality Insights][personality_insights] service enables applications to derive insights from social media, enterprise data, or other digital communications. The service uses linguistic analytics to infer individuals' intrinsic personality characteristics, including Big Five, Needs, and Values, from digital communications such as email, text messages, tweets, and forum posts. The service can automatically infer, from potentially noisy social media, portraits of individuals that reflect their personality characteristics.
718+
719+
```cs
720+
PersonalityInsights m_personalityInsights = new PersonalityInsights();
721+
722+
void Start () {
723+
string dataPath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/personalityInsights.json";
724+
725+
if(!m_personalityInsights.GetProfile(OnGetProfile, dataPath, DataModels.ContentType.TEXT_PLAIN, DataModels.Language.ENGLISH))
726+
Log.Debug("ExamplePersonalityInsights", "Failed to get profile!");
727+
}
728+
729+
private void OnGetProfile(DataModels.Profile profile, string data)
730+
{
731+
Log.Debug("ExamplePersonalityInsights", "data: {0}", data);
732+
if(profile != null)
733+
{
734+
if(!string.IsNullOrEmpty(profile.id))
735+
Log.Debug("ExamplePersonalityInsights", "id: {0}", profile.id);
736+
if(!string.IsNullOrEmpty(profile.source))
737+
Log.Debug("ExamplePersonalityInsights", "source: {0}", profile.source);
738+
if(!string.IsNullOrEmpty(profile.processed_lang))
739+
Log.Debug("ExamplePersonalityInsights", "proccessed_lang: {0}", profile.processed_lang);
740+
if(!string.IsNullOrEmpty(profile.word_count))
741+
Log.Debug("ExamplePersonalityInsights", "word_count: {0}", profile.word_count);
742+
if(!string.IsNullOrEmpty(profile.word_count_message))
743+
Log.Debug("ExamplePersonalityInsights", "word_count_message: {0}", profile.word_count_message);
744+
745+
if(profile.tree != null)
746+
{
747+
LogTraitTree(profile.tree);
748+
}
749+
}
750+
else
751+
{
752+
Log.Debug("ExamplePersonalityInsights", "Failed to get profile!");
753+
}
754+
}
755+
756+
private void LogTraitTree(DataModels.TraitTreeNode traitTreeNode)
757+
{
758+
if(!string.IsNullOrEmpty(traitTreeNode.id))
759+
Log.Debug("ExamplePersonalityInsights", "id: {0}", traitTreeNode.id);
760+
if(!string.IsNullOrEmpty(traitTreeNode.name))
761+
Log.Debug("ExamplePersonalityInsights", "name: {0}", traitTreeNode.name);
762+
if(!string.IsNullOrEmpty(traitTreeNode.category))
763+
Log.Debug("ExamplePersonalityInsights", "category: {0}", traitTreeNode.category);
764+
if(!string.IsNullOrEmpty(traitTreeNode.percentage))
765+
Log.Debug("ExamplePersonalityInsights", "percentage: {0}", traitTreeNode.percentage);
766+
if(!string.IsNullOrEmpty(traitTreeNode.sampling_error))
767+
Log.Debug("ExamplePersonalityInsights", "sampling_error: {0}", traitTreeNode.sampling_error);
768+
if(!string.IsNullOrEmpty(traitTreeNode.raw_score))
769+
Log.Debug("ExamplePersonalityInsights", "raw_score: {0}", traitTreeNode.raw_score);
770+
if(!string.IsNullOrEmpty(traitTreeNode.raw_sampling_error))
771+
Log.Debug("ExamplePersonalityInsights", "raw_sampling_error: {0}", traitTreeNode.raw_sampling_error);
772+
if(traitTreeNode.children != null && traitTreeNode.children.Length > 0)
773+
foreach(DataModels.TraitTreeNode childNode in traitTreeNode.children)
774+
LogTraitTree(childNode);
775+
}
776+
```
777+
778+
779+
715780

716781
## Developing a basic application in one minute
717782
You can quickly develop a basic application that uses the Speech to Text service and the Natural Language Classifier service by using the prefabs that come with the SDK. Ensure that you prepare the test data before you complete the the following steps:
@@ -762,3 +827,4 @@ See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
762827
[tradeoff_analytics]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/tradeoff-analytics/
763828
[conversation]:http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/conversation/
764829
[visual_recognition]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/visual-recognition/api/v3/
830+
[personality_insights]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/personality-insights/api/v2/

0 commit comments

Comments
 (0)