Skip to content

Commit 040e8ab

Browse files
Merge branch 'develop' into feature-sttStreamingTest
2 parents d55e742 + 7b10cac commit 040e8ab

23 files changed

+1163
-84
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Change Log
22
==========
3+
## Version 0.12.0
4+
_2016_10_27_
5+
* New: Added streaming `SpeechToText` example.
6+
* New: Abstraction for `Personality Insights V3`
7+
38
## Version 0.11.0
49
_2016_10_27_
510
* New: Abstracted `Speech to Text` customization methods.

Examples/ServiceExamples/Scripts/ExamplePersonalityInsights.cs renamed to Examples/ServiceExamples/Scripts/ExamplePersonalityInsightsV2.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
*/
1717

1818
using UnityEngine;
19-
using System.Collections;
2019
using IBM.Watson.DeveloperCloud.Services.PersonalityInsights.v2;
2120
using IBM.Watson.DeveloperCloud.Logging;
2221

23-
public class ExamplePersonalityInsights : MonoBehaviour {
22+
public class ExamplePersonalityInsightsV2 : MonoBehaviour
23+
{
2424
PersonalityInsights m_personalityInsights = new PersonalityInsights();
2525

2626
void Start ()
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
/**
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using UnityEngine;
19+
using IBM.Watson.DeveloperCloud.Services.PersonalityInsights.v3;
20+
using IBM.Watson.DeveloperCloud.Logging;
21+
22+
public class ExamplePersonalityInsightsV3 : MonoBehaviour
23+
{
24+
PersonalityInsights m_personalityInsights = new PersonalityInsights();
25+
private string testString = "<text-here>";
26+
private string dataPath;
27+
28+
void Start()
29+
{
30+
LogSystem.InstallDefaultReactors();
31+
32+
dataPath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/personalityInsights.json";
33+
34+
if (!m_personalityInsights.GetProfile(OnGetProfileJson, dataPath, ContentType.TEXT_HTML, ContentLanguage.ENGLISH, ContentType.APPLICATION_JSON, AcceptLanguage.ENGLISH, true, true, true))
35+
Log.Debug("ExamplePersonalityInsights", "Failed to get profile!");
36+
37+
if (!m_personalityInsights.GetProfile(OnGetProfileText, testString, ContentType.TEXT_HTML, ContentLanguage.ENGLISH, ContentType.APPLICATION_JSON, AcceptLanguage.ENGLISH, true, true, true))
38+
Log.Debug("ExamplePersonalityInsights", "Failed to get profile!");
39+
}
40+
private void OnGetProfileText(Profile profile, string data)
41+
{
42+
if (profile != null)
43+
{
44+
if (!string.IsNullOrEmpty(profile.processed_language))
45+
Log.Debug("TestPersonalityInsightsV3", "processed_language: {0}", profile.processed_language);
46+
47+
Log.Debug("TestPersonalityInsightsV3", "word_count: {0}", profile.word_count);
48+
49+
if (!string.IsNullOrEmpty(profile.word_count_message))
50+
Log.Debug("TestPersonalityInsightsV3", "word_count_message: {0}", profile.word_count_message);
51+
52+
if (profile.personality != null && profile.personality.Length > 0)
53+
{
54+
Log.Debug("TestPersonalityInsightsV3", "Personality trait tree");
55+
foreach (TraitTreeNode node in profile.personality)
56+
LogTraitTree(node);
57+
}
58+
59+
if (profile.values != null && profile.values.Length > 0)
60+
{
61+
Log.Debug("TestPersonalityInsightsV3", "Values trait tree");
62+
foreach (TraitTreeNode node in profile.values)
63+
LogTraitTree(node);
64+
}
65+
66+
if (profile.needs != null && profile.personality.Length > 0)
67+
{
68+
Log.Debug("TestPersonalityInsightsV3", "Needs trait tree");
69+
foreach (TraitTreeNode node in profile.needs)
70+
LogTraitTree(node);
71+
}
72+
73+
if (profile.behavior != null && profile.behavior.Length > 0)
74+
{
75+
Log.Debug("TestPersonalityInsightsV3", "Behavior tree");
76+
foreach (BehaviorNode behavior in profile.behavior)
77+
{
78+
Log.Debug("TestPersonalityInsightsV3", "trait_id: {0}", behavior.trait_id);
79+
Log.Debug("TestPersonalityInsightsV3", "name: {0}", behavior.name);
80+
Log.Debug("TestPersonalityInsightsV3", "category: {0}", behavior.category);
81+
Log.Debug("TestPersonalityInsightsV3", "percentage: {0}", behavior.percentage.ToString());
82+
Log.Debug("TestPersonalityInsightsV3", "----------------");
83+
}
84+
}
85+
86+
if (profile.consumption_preferences != null && profile.consumption_preferences.Length > 0)
87+
{
88+
Log.Debug("TestPersonalityInsightsV3", "ConsumptionPreferencesCategories");
89+
foreach (ConsumptionPreferencesCategoryNode categoryNode in profile.consumption_preferences)
90+
LogConsumptionPreferencesCategory(categoryNode);
91+
}
92+
}
93+
}
94+
95+
private void OnGetProfileJson(Profile profile, string data)
96+
{
97+
if (profile != null)
98+
{
99+
if (!string.IsNullOrEmpty(profile.processed_language))
100+
Log.Debug("TestPersonalityInsightsV3", "processed_language: {0}", profile.processed_language);
101+
102+
Log.Debug("TestPersonalityInsightsV3", "word_count: {0}", profile.word_count);
103+
104+
if (!string.IsNullOrEmpty(profile.word_count_message))
105+
Log.Debug("TestPersonalityInsightsV3", "word_count_message: {0}", profile.word_count_message);
106+
107+
if (profile.personality != null && profile.personality.Length > 0)
108+
{
109+
Log.Debug("TestPersonalityInsightsV3", "Personality trait tree");
110+
foreach (TraitTreeNode node in profile.personality)
111+
LogTraitTree(node);
112+
}
113+
114+
if (profile.values != null && profile.values.Length > 0)
115+
{
116+
Log.Debug("TestPersonalityInsightsV3", "Values trait tree");
117+
foreach (TraitTreeNode node in profile.values)
118+
LogTraitTree(node);
119+
}
120+
121+
if (profile.needs != null && profile.personality.Length > 0)
122+
{
123+
Log.Debug("TestPersonalityInsightsV3", "Needs trait tree");
124+
foreach (TraitTreeNode node in profile.needs)
125+
LogTraitTree(node);
126+
}
127+
128+
if (profile.behavior != null && profile.behavior.Length > 0)
129+
{
130+
Log.Debug("TestPersonalityInsightsV3", "Behavior tree");
131+
foreach (BehaviorNode behavior in profile.behavior)
132+
{
133+
Log.Debug("TestPersonalityInsightsV3", "trait_id: {0}", behavior.trait_id);
134+
Log.Debug("TestPersonalityInsightsV3", "name: {0}", behavior.name);
135+
Log.Debug("TestPersonalityInsightsV3", "category: {0}", behavior.category);
136+
Log.Debug("TestPersonalityInsightsV3", "percentage: {0}", behavior.percentage.ToString());
137+
Log.Debug("TestPersonalityInsightsV3", "----------------");
138+
}
139+
}
140+
141+
if (profile.consumption_preferences != null && profile.consumption_preferences.Length > 0)
142+
{
143+
Log.Debug("TestPersonalityInsightsV3", "ConsumptionPreferencesCategories");
144+
foreach (ConsumptionPreferencesCategoryNode categoryNode in profile.consumption_preferences)
145+
LogConsumptionPreferencesCategory(categoryNode);
146+
}
147+
}
148+
}
149+
150+
private void LogTraitTree(TraitTreeNode traitTreeNode)
151+
{
152+
Log.Debug("TestPersonalityInsightsV3", "trait_id: {0} | name: {1} | category: {2} | percentile: {3} | raw_score: {4}",
153+
string.IsNullOrEmpty(traitTreeNode.trait_id) ? "null" : traitTreeNode.trait_id,
154+
string.IsNullOrEmpty(traitTreeNode.name) ? "null" : traitTreeNode.name,
155+
string.IsNullOrEmpty(traitTreeNode.category) ? "null" : traitTreeNode.category,
156+
string.IsNullOrEmpty(traitTreeNode.percentile.ToString()) ? "null" : traitTreeNode.percentile.ToString(),
157+
string.IsNullOrEmpty(traitTreeNode.raw_score.ToString()) ? "null" : traitTreeNode.raw_score.ToString());
158+
159+
if (traitTreeNode.children != null && traitTreeNode.children.Length > 0)
160+
foreach (TraitTreeNode childNode in traitTreeNode.children)
161+
LogTraitTree(childNode);
162+
}
163+
164+
private void LogConsumptionPreferencesCategory(ConsumptionPreferencesCategoryNode categoryNode)
165+
{
166+
Log.Debug("TestPersonalityInsightsV3", "consumption_preference_category_id: {0} | name: {1}", categoryNode.consumption_preference_category_id, categoryNode.name);
167+
168+
foreach (ConsumptionPreferencesNode preferencesNode in categoryNode.consumption_preferences)
169+
Log.Debug("TestPersonalityInsightsV3", "\t consumption_preference_id: {0} | name: {1} | score: {2}",
170+
string.IsNullOrEmpty(preferencesNode.consumption_preference_id) ? "null" : preferencesNode.consumption_preference_id,
171+
string.IsNullOrEmpty(preferencesNode.name) ? "null" : preferencesNode.name,
172+
string.IsNullOrEmpty(preferencesNode.score.ToString()) ? "null" : preferencesNode.score.ToString());
173+
}
174+
}

Examples/ServiceExamples/Scripts/ExamplePersonalityInsightsV3.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/ServiceExamples/ServiceExamples.unity

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RenderSettings:
3737
m_ReflectionIntensity: 1
3838
m_CustomReflection: {fileID: 0}
3939
m_Sun: {fileID: 0}
40-
m_IndirectSpecularColor: {r: 0.3735645, g: 0.38112062, b: 0.35887584, a: 1}
40+
m_IndirectSpecularColor: {r: 0.3735644, g: 0.38112032, b: 0.35887682, a: 1}
4141
--- !u!157 &3
4242
LightmapSettings:
4343
m_ObjectHideFlags: 0
@@ -209,7 +209,7 @@ Transform:
209209
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
210210
m_Children: []
211211
m_Father: {fileID: 0}
212-
m_RootOrder: 11
212+
m_RootOrder: 12
213213
--- !u!1 &725710367
214214
GameObject:
215215
m_ObjectHideFlags: 0
@@ -336,6 +336,46 @@ Transform:
336336
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
337337
m_Children: []
338338
m_Father: {fileID: 0}
339+
m_RootOrder: 11
340+
--- !u!1 &854511683
341+
GameObject:
342+
m_ObjectHideFlags: 0
343+
m_PrefabParentObject: {fileID: 0}
344+
m_PrefabInternal: {fileID: 0}
345+
serializedVersion: 4
346+
m_Component:
347+
- 4: {fileID: 854511685}
348+
- 114: {fileID: 854511684}
349+
m_Layer: 0
350+
m_Name: ExamplePersonalityInsightsV3
351+
m_TagString: Untagged
352+
m_Icon: {fileID: 0}
353+
m_NavMeshLayer: 0
354+
m_StaticEditorFlags: 0
355+
m_IsActive: 0
356+
--- !u!114 &854511684
357+
MonoBehaviour:
358+
m_ObjectHideFlags: 0
359+
m_PrefabParentObject: {fileID: 0}
360+
m_PrefabInternal: {fileID: 0}
361+
m_GameObject: {fileID: 854511683}
362+
m_Enabled: 1
363+
m_EditorHideFlags: 0
364+
m_Script: {fileID: 11500000, guid: cd2e3d3910ea1bd46b55eb5943a057f7, type: 3}
365+
m_Name:
366+
m_EditorClassIdentifier:
367+
--- !u!4 &854511685
368+
Transform:
369+
m_ObjectHideFlags: 0
370+
m_PrefabParentObject: {fileID: 0}
371+
m_PrefabInternal: {fileID: 0}
372+
m_GameObject: {fileID: 854511683}
373+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
374+
m_LocalPosition: {x: 0, y: 0, z: 0}
375+
m_LocalScale: {x: 1, y: 1, z: 1}
376+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
377+
m_Children: []
378+
m_Father: {fileID: 0}
339379
m_RootOrder: 10
340380
--- !u!1 &859102722
341381
GameObject:
@@ -416,7 +456,7 @@ Transform:
416456
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
417457
m_Children: []
418458
m_Father: {fileID: 0}
419-
m_RootOrder: 12
459+
m_RootOrder: 13
420460
--- !u!1 &1073418922
421461
GameObject:
422462
m_ObjectHideFlags: 0
@@ -472,7 +512,7 @@ GameObject:
472512
m_Icon: {fileID: 0}
473513
m_NavMeshLayer: 0
474514
m_StaticEditorFlags: 0
475-
m_IsActive: 1
515+
m_IsActive: 0
476516
--- !u!114 &1160237479
477517
MonoBehaviour:
478518
m_ObjectHideFlags: 0
@@ -577,7 +617,7 @@ Transform:
577617
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
578618
m_Children: []
579619
m_Father: {fileID: 0}
580-
m_RootOrder: 13
620+
m_RootOrder: 14
581621
--- !u!1 &1713392457
582622
GameObject:
583623
m_ObjectHideFlags: 0
@@ -668,7 +708,7 @@ GameObject:
668708
- 4: {fileID: 2004886373}
669709
- 114: {fileID: 2004886372}
670710
m_Layer: 0
671-
m_Name: ExamplePersonalityInsights
711+
m_Name: ExamplePersonalityInsightsV2
672712
m_TagString: Untagged
673713
m_Icon: {fileID: 0}
674714
m_NavMeshLayer: 0

0 commit comments

Comments
 (0)