Skip to content

Commit 05ce870

Browse files
committed
Merge branch 'feature-26-tradeoffAnalytics' into develop
2 parents 78aff18 + 8901a2d commit 05ce870

19 files changed

+1401
-0
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+
}

Examples/ServiceExamples/Scripts/ExampleToneAnalyzer.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.
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+
}

Examples/ServiceExamples/Scripts/ExampleTradeoffAnalytics.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: 78 additions & 0 deletions
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
@@ -249,6 +288,45 @@ Transform:
249288
m_Children: []
250289
m_Father: {fileID: 0}
251290
m_RootOrder: 5
291+
--- !u!1 &1073418922
292+
GameObject:
293+
m_ObjectHideFlags: 0
294+
m_PrefabParentObject: {fileID: 0}
295+
m_PrefabInternal: {fileID: 0}
296+
serializedVersion: 4
297+
m_Component:
298+
- 4: {fileID: 1073418924}
299+
- 114: {fileID: 1073418923}
300+
m_Layer: 0
301+
m_Name: ExampleToneAnalyzer
302+
m_TagString: Untagged
303+
m_Icon: {fileID: 0}
304+
m_NavMeshLayer: 0
305+
m_StaticEditorFlags: 0
306+
m_IsActive: 0
307+
--- !u!114 &1073418923
308+
MonoBehaviour:
309+
m_ObjectHideFlags: 0
310+
m_PrefabParentObject: {fileID: 0}
311+
m_PrefabInternal: {fileID: 0}
312+
m_GameObject: {fileID: 1073418922}
313+
m_Enabled: 1
314+
m_EditorHideFlags: 0
315+
m_Script: {fileID: 11500000, guid: d4dd8308135b04c28945ad3e8489aa7f, type: 3}
316+
m_Name:
317+
m_EditorClassIdentifier:
318+
--- !u!4 &1073418924
319+
Transform:
320+
m_ObjectHideFlags: 0
321+
m_PrefabParentObject: {fileID: 0}
322+
m_PrefabInternal: {fileID: 0}
323+
m_GameObject: {fileID: 1073418922}
324+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
325+
m_LocalPosition: {x: 0, y: 0, z: 0}
326+
m_LocalScale: {x: 1, y: 1, z: 1}
327+
m_Children: []
328+
m_Father: {fileID: 0}
329+
m_RootOrder: 6
252330
--- !u!1 &1160237478
253331
GameObject:
254332
m_ObjectHideFlags: 0

Scripts/Services/ToneAnalyzer.meta

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

0 commit comments

Comments
 (0)