Skip to content

Commit 5318405

Browse files
committed
formatting
1 parent 92091f7 commit 5318405

File tree

4 files changed

+740
-738
lines changed

4 files changed

+740
-738
lines changed

Examples/ServiceExamples/Scripts/ExamplePersonalityInsightsV3.cs

Lines changed: 150 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -21,153 +21,154 @@
2121

2222
public class ExamplePersonalityInsightsV3 : MonoBehaviour
2323
{
24-
PersonalityInsights m_personalityInsights = new PersonalityInsights();
25-
private string testString = "<text-here>";
26-
private string dataPath;
27-
28-
void Start () {
29-
LogSystem.InstallDefaultReactors();
30-
31-
dataPath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/personalityInsights.json";
32-
33-
if(!m_personalityInsights.GetProfile(OnGetProfileJson, dataPath, ContentType.TEXT_HTML, ContentLanguage.ENGLISH, ContentType.APPLICATION_JSON, AcceptLanguage.ENGLISH, true, true, true))
34-
Log.Debug("ExamplePersonalityInsights", "Failed to get profile!");
35-
36-
if (!m_personalityInsights.GetProfile(OnGetProfileText, testString, ContentType.TEXT_HTML, ContentLanguage.ENGLISH, ContentType.APPLICATION_JSON, AcceptLanguage.ENGLISH, true, true, true))
37-
Log.Debug("ExamplePersonalityInsights", "Failed to get profile!");
38-
}
39-
private void OnGetProfileText(Profile profile, string data)
40-
{
41-
if (profile != null)
42-
{
43-
if (!string.IsNullOrEmpty(profile.processed_language))
44-
Log.Debug("TestPersonalityInsightsV3", "processed_language: {0}", profile.processed_language);
45-
46-
Log.Debug("TestPersonalityInsightsV3", "word_count: {0}", profile.word_count);
47-
48-
if (!string.IsNullOrEmpty(profile.word_count_message))
49-
Log.Debug("TestPersonalityInsightsV3", "word_count_message: {0}", profile.word_count_message);
50-
51-
if (profile.personality != null && profile.personality.Length > 0)
52-
{
53-
Log.Debug("TestPersonalityInsightsV3", "Personality trait tree");
54-
foreach (TraitTreeNode node in profile.personality)
55-
LogTraitTree(node);
56-
}
57-
58-
if (profile.values != null && profile.values.Length > 0)
59-
{
60-
Log.Debug("TestPersonalityInsightsV3", "Values trait tree");
61-
foreach (TraitTreeNode node in profile.values)
62-
LogTraitTree(node);
63-
}
64-
65-
if (profile.needs != null && profile.personality.Length > 0)
66-
{
67-
Log.Debug("TestPersonalityInsightsV3", "Needs trait tree");
68-
foreach (TraitTreeNode node in profile.needs)
69-
LogTraitTree(node);
70-
}
71-
72-
if (profile.behavior != null && profile.behavior.Length > 0)
73-
{
74-
Log.Debug("TestPersonalityInsightsV3", "Behavior tree");
75-
foreach (BehaviorNode behavior in profile.behavior)
76-
{
77-
Log.Debug("TestPersonalityInsightsV3", "trait_id: {0}", behavior.trait_id);
78-
Log.Debug("TestPersonalityInsightsV3", "name: {0}", behavior.name);
79-
Log.Debug("TestPersonalityInsightsV3", "category: {0}", behavior.category);
80-
Log.Debug("TestPersonalityInsightsV3", "percentage: {0}", behavior.percentage.ToString());
81-
Log.Debug("TestPersonalityInsightsV3", "----------------");
82-
}
83-
}
84-
85-
if (profile.consumption_preferences != null && profile.consumption_preferences.Length > 0)
86-
{
87-
Log.Debug("TestPersonalityInsightsV3", "ConsumptionPreferencesCategories");
88-
foreach (ConsumptionPreferencesCategoryNode categoryNode in profile.consumption_preferences)
89-
LogConsumptionPreferencesCategory(categoryNode);
90-
}
91-
}
92-
}
93-
94-
private void OnGetProfileJson(Profile profile, string data)
95-
{
96-
if (profile != null)
97-
{
98-
if (!string.IsNullOrEmpty(profile.processed_language))
99-
Log.Debug("TestPersonalityInsightsV3", "processed_language: {0}", profile.processed_language);
100-
101-
Log.Debug("TestPersonalityInsightsV3", "word_count: {0}", profile.word_count);
102-
103-
if (!string.IsNullOrEmpty(profile.word_count_message))
104-
Log.Debug("TestPersonalityInsightsV3", "word_count_message: {0}", profile.word_count_message);
105-
106-
if (profile.personality != null && profile.personality.Length > 0)
107-
{
108-
Log.Debug("TestPersonalityInsightsV3", "Personality trait tree");
109-
foreach (TraitTreeNode node in profile.personality)
110-
LogTraitTree(node);
111-
}
112-
113-
if (profile.values != null && profile.values.Length > 0)
114-
{
115-
Log.Debug("TestPersonalityInsightsV3", "Values trait tree");
116-
foreach (TraitTreeNode node in profile.values)
117-
LogTraitTree(node);
118-
}
119-
120-
if (profile.needs != null && profile.personality.Length > 0)
121-
{
122-
Log.Debug("TestPersonalityInsightsV3", "Needs trait tree");
123-
foreach (TraitTreeNode node in profile.needs)
124-
LogTraitTree(node);
125-
}
126-
127-
if (profile.behavior != null && profile.behavior.Length > 0)
128-
{
129-
Log.Debug("TestPersonalityInsightsV3", "Behavior tree");
130-
foreach (BehaviorNode behavior in profile.behavior)
131-
{
132-
Log.Debug("TestPersonalityInsightsV3", "trait_id: {0}", behavior.trait_id);
133-
Log.Debug("TestPersonalityInsightsV3", "name: {0}", behavior.name);
134-
Log.Debug("TestPersonalityInsightsV3", "category: {0}", behavior.category);
135-
Log.Debug("TestPersonalityInsightsV3", "percentage: {0}", behavior.percentage.ToString());
136-
Log.Debug("TestPersonalityInsightsV3", "----------------");
137-
}
138-
}
139-
140-
if (profile.consumption_preferences != null && profile.consumption_preferences.Length > 0)
141-
{
142-
Log.Debug("TestPersonalityInsightsV3", "ConsumptionPreferencesCategories");
143-
foreach (ConsumptionPreferencesCategoryNode categoryNode in profile.consumption_preferences)
144-
LogConsumptionPreferencesCategory(categoryNode);
145-
}
146-
}
147-
}
148-
149-
private void LogTraitTree(TraitTreeNode traitTreeNode)
150-
{
151-
Log.Debug("TestPersonalityInsightsV3", "trait_id: {0} | name: {1} | category: {2} | percentile: {3} | raw_score: {4}",
152-
string.IsNullOrEmpty(traitTreeNode.trait_id) ? "null" : traitTreeNode.trait_id,
153-
string.IsNullOrEmpty(traitTreeNode.name) ? "null" : traitTreeNode.name,
154-
string.IsNullOrEmpty(traitTreeNode.category) ? "null" : traitTreeNode.category,
155-
string.IsNullOrEmpty(traitTreeNode.percentile.ToString()) ? "null" : traitTreeNode.percentile.ToString(),
156-
string.IsNullOrEmpty(traitTreeNode.raw_score.ToString()) ? "null" : traitTreeNode.raw_score.ToString());
157-
158-
if (traitTreeNode.children != null && traitTreeNode.children.Length > 0)
159-
foreach (TraitTreeNode childNode in traitTreeNode.children)
160-
LogTraitTree(childNode);
161-
}
162-
163-
private void LogConsumptionPreferencesCategory(ConsumptionPreferencesCategoryNode categoryNode)
164-
{
165-
Log.Debug("TestPersonalityInsightsV3", "consumption_preference_category_id: {0} | name: {1}", categoryNode.consumption_preference_category_id, categoryNode.name);
166-
167-
foreach (ConsumptionPreferencesNode preferencesNode in categoryNode.consumption_preferences)
168-
Log.Debug("TestPersonalityInsightsV3", "\t consumption_preference_id: {0} | name: {1} | score: {2}",
169-
string.IsNullOrEmpty(preferencesNode.consumption_preference_id) ? "null" : preferencesNode.consumption_preference_id,
170-
string.IsNullOrEmpty(preferencesNode.name) ? "null" : preferencesNode.name,
171-
string.IsNullOrEmpty(preferencesNode.score.ToString()) ? "null" : preferencesNode.score.ToString());
172-
}
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+
}
173174
}

0 commit comments

Comments
 (0)