Skip to content

Commit 8901a2d

Browse files
committed
Tone Analyzer v3 complete
1 parent 3b4f5ec commit 8901a2d

File tree

14 files changed

+361
-238
lines changed

14 files changed

+361
-238
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
19+
using UnityEngine;
20+
using System.Collections;
21+
using IBM.Watson.DeveloperCloud.Services.ToneAnalyzer.v3;
22+
23+
public class ExampleToneAnalyzer : MonoBehaviour {
24+
ToneAnalyzer m_ToneAnalyzer = new ToneAnalyzer();
25+
string m_StringToTestTone = "This service enables people to discover and understand, and revise the impact of tone in their content. It uses linguistic analysis to detect and interpret emotional, social, and language cues found in text.";
26+
27+
void Start () {
28+
m_ToneAnalyzer.GetToneAnalyze( OnGetToneAnalyze, m_StringToTestTone, "TEST");
29+
}
30+
31+
private void OnGetToneAnalyze( ToneAnalyzerResponse resp , string data)
32+
{
33+
Debug.Log("Response: " +resp + " - " + data);
34+
}
35+
}

Scripts/Services/ToneAnalyzer/v3/DataModels.cs.meta renamed to Examples/ServiceExamples/Scripts/ExampleToneAnalyzer.cs.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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+
19+
using UnityEngine;
20+
using System.Collections;
21+
using System.Collections.Generic;
22+
using IBM.Watson.DeveloperCloud.Services.TradeoffAnalytics.v1;
23+
24+
public class ExampleTradeoffAnalytics : MonoBehaviour {
25+
TradeoffAnalytics m_TradeoffAnalytics = new TradeoffAnalytics();
26+
27+
void Start () {
28+
Problem problemToSolve = new Problem();
29+
problemToSolve.subject = "Test Subject";
30+
31+
List<Column> listColumn = new List<Column>();
32+
Column columnPrice = new Column();
33+
columnPrice.description = "Price Column to minimize";
34+
columnPrice.range = new ValueRange();
35+
((ValueRange)columnPrice.range).high = 600;
36+
((ValueRange)columnPrice.range).low = 0;
37+
columnPrice.type = "numeric";
38+
columnPrice.key = "price";
39+
columnPrice.full_name = "Price";
40+
columnPrice.goal = "min";
41+
columnPrice.is_objective = true;
42+
columnPrice.format = "$####0.00";
43+
44+
Column columnWeight = new Column();
45+
columnWeight.description = "Weight Column to minimize";
46+
columnWeight.type = "numeric";
47+
columnWeight.key = "weight";
48+
columnWeight.full_name = "Weight";
49+
columnWeight.goal = "min";
50+
columnWeight.is_objective = true;
51+
columnWeight.format = "####0 g";
52+
53+
Column columnBrandName = new Column();
54+
columnBrandName.description = "All Brand Names";
55+
columnBrandName.type = "categorical";
56+
columnBrandName.key = "brand";
57+
columnBrandName.full_name = "Brand";
58+
columnBrandName.goal = "max";
59+
columnBrandName.is_objective = true;
60+
columnBrandName.preference = new string[]{"Samsung", "Apple", "HTC"};
61+
columnBrandName.range = new CategoricalRange();
62+
((CategoricalRange)columnBrandName.range).keys = new string[]{"Samsung", "Apple", "HTC"};
63+
64+
listColumn.Add(columnPrice);
65+
listColumn.Add(columnWeight);
66+
// listColumn.Add(columnBrandName);
67+
68+
problemToSolve.columns = listColumn.ToArray();
69+
70+
71+
List<Option> listOption = new List<Option>();
72+
73+
Option option1 = new Option();
74+
option1.key = "1";
75+
option1.name = "Samsung Galaxy S4";
76+
option1.values = new TestDataValue();
77+
(option1.values as TestDataValue).weight = 130;
78+
(option1.values as TestDataValue).brand = "Samsung";
79+
(option1.values as TestDataValue).price = 249;
80+
listOption.Add(option1);
81+
82+
Option option2 = new Option();
83+
option2.key = "2";
84+
option2.name = "Apple iPhone 5";
85+
option2.values = new TestDataValue();
86+
(option2.values as TestDataValue).weight = 112;
87+
(option2.values as TestDataValue).brand = "Apple";
88+
(option2.values as TestDataValue).price = 599;
89+
listOption.Add(option2);
90+
91+
Option option3 = new Option();
92+
option3.key = "3";
93+
option3.name = "HTC One";
94+
option3.values = new TestDataValue();
95+
(option3.values as TestDataValue).weight = 143;
96+
(option3.values as TestDataValue).brand = "HTC";
97+
(option3.values as TestDataValue).price = 299;
98+
listOption.Add(option3);
99+
100+
problemToSolve.options = listOption.ToArray();
101+
102+
m_TradeoffAnalytics.GetDilemma( OnGetDilemma, problemToSolve, false );
103+
}
104+
105+
private void OnGetDilemma( DilemmasResponse resp )
106+
{
107+
Debug.Log("Response: " + resp);
108+
}
109+
110+
/// <summary>
111+
/// Application data value.
112+
/// </summary>
113+
public class TestDataValue : IBM.Watson.DeveloperCloud.Services.TradeoffAnalytics.v1.ApplicationDataValue
114+
{
115+
public double price { get; set; }
116+
public double weight { get; set; }
117+
public string brand { get; set; }
118+
}
119+
120+
/// <summary>
121+
/// Application data.
122+
/// </summary>
123+
public class TestData : IBM.Watson.DeveloperCloud.Services.TradeoffAnalytics.v1.ApplicationData
124+
{
125+
126+
}
127+
}

Scripts/Services/ToneAnalyzer/v3/ToneAnalyzer.cs.meta renamed to Examples/ServiceExamples/Scripts/ExampleTradeoffAnalytics.cs.meta

Lines changed: 2 additions & 2 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: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,45 @@ NavMeshSettings:
8585
cellSize: 0.16666667
8686
manualCellSize: 0
8787
m_NavMeshData: {fileID: 0}
88+
--- !u!1 &473286772
89+
GameObject:
90+
m_ObjectHideFlags: 0
91+
m_PrefabParentObject: {fileID: 0}
92+
m_PrefabInternal: {fileID: 0}
93+
serializedVersion: 4
94+
m_Component:
95+
- 4: {fileID: 473286774}
96+
- 114: {fileID: 473286773}
97+
m_Layer: 0
98+
m_Name: ExampleTradeoffAnalytics
99+
m_TagString: Untagged
100+
m_Icon: {fileID: 0}
101+
m_NavMeshLayer: 0
102+
m_StaticEditorFlags: 0
103+
m_IsActive: 1
104+
--- !u!114 &473286773
105+
MonoBehaviour:
106+
m_ObjectHideFlags: 0
107+
m_PrefabParentObject: {fileID: 0}
108+
m_PrefabInternal: {fileID: 0}
109+
m_GameObject: {fileID: 473286772}
110+
m_Enabled: 1
111+
m_EditorHideFlags: 0
112+
m_Script: {fileID: 11500000, guid: 068b8c76641e04cb98498e273fdba9ae, type: 3}
113+
m_Name:
114+
m_EditorClassIdentifier:
115+
--- !u!4 &473286774
116+
Transform:
117+
m_ObjectHideFlags: 0
118+
m_PrefabParentObject: {fileID: 0}
119+
m_PrefabInternal: {fileID: 0}
120+
m_GameObject: {fileID: 473286772}
121+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
122+
m_LocalPosition: {x: 0, y: 0, z: 0}
123+
m_LocalScale: {x: 1, y: 1, z: 1}
124+
m_Children: []
125+
m_Father: {fileID: 0}
126+
m_RootOrder: 7
88127
--- !u!1 &525603453
89128
GameObject:
90129
m_ObjectHideFlags: 0
@@ -210,6 +249,45 @@ Transform:
210249
m_Children: []
211250
m_Father: {fileID: 0}
212251
m_RootOrder: 5
252+
--- !u!1 &1073418922
253+
GameObject:
254+
m_ObjectHideFlags: 0
255+
m_PrefabParentObject: {fileID: 0}
256+
m_PrefabInternal: {fileID: 0}
257+
serializedVersion: 4
258+
m_Component:
259+
- 4: {fileID: 1073418924}
260+
- 114: {fileID: 1073418923}
261+
m_Layer: 0
262+
m_Name: ExampleToneAnalyzer
263+
m_TagString: Untagged
264+
m_Icon: {fileID: 0}
265+
m_NavMeshLayer: 0
266+
m_StaticEditorFlags: 0
267+
m_IsActive: 0
268+
--- !u!114 &1073418923
269+
MonoBehaviour:
270+
m_ObjectHideFlags: 0
271+
m_PrefabParentObject: {fileID: 0}
272+
m_PrefabInternal: {fileID: 0}
273+
m_GameObject: {fileID: 1073418922}
274+
m_Enabled: 1
275+
m_EditorHideFlags: 0
276+
m_Script: {fileID: 11500000, guid: d4dd8308135b04c28945ad3e8489aa7f, type: 3}
277+
m_Name:
278+
m_EditorClassIdentifier:
279+
--- !u!4 &1073418924
280+
Transform:
281+
m_ObjectHideFlags: 0
282+
m_PrefabParentObject: {fileID: 0}
283+
m_PrefabInternal: {fileID: 0}
284+
m_GameObject: {fileID: 1073418922}
285+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
286+
m_LocalPosition: {x: 0, y: 0, z: 0}
287+
m_LocalScale: {x: 1, y: 1, z: 1}
288+
m_Children: []
289+
m_Father: {fileID: 0}
290+
m_RootOrder: 6
213291
--- !u!1 &1160237478
214292
GameObject:
215293
m_ObjectHideFlags: 0
@@ -225,7 +303,7 @@ GameObject:
225303
m_Icon: {fileID: 0}
226304
m_NavMeshLayer: 0
227305
m_StaticEditorFlags: 0
228-
m_IsActive: 1
306+
m_IsActive: 0
229307
--- !u!114 &1160237479
230308
MonoBehaviour:
231309
m_ObjectHideFlags: 0

0 commit comments

Comments
 (0)