Skip to content

Commit 6b8ed30

Browse files
committed
merged in develop, encrypt config
2 parents f8ca338 + 02d8767 commit 6b8ed30

16 files changed

+701
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ LICENSE.meta
5050
CHANGELOG.md.meta
5151
README.md.meta
5252
Travis.meta
53+
exclude-filter.txt
54+
exclude-filter.txt.meta
5355
/Travis/UnityTestProject/Assets/StreamingAssets/Config.json
5456
/Travis/UnityTestProject/Assets/StreamingAssets/Config.json.meta
5557
/Travis/UnityTestProject/Assets/StreamingAssets/Config.json.enc.meta

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.6.0
4+
_2016-07-15_
5+
6+
* New: Added `Document Conversion` abstraction
7+
38
## Version 0.5.0
49

510
_2016-06-24_

Config.json.enc

848 Bytes
Binary file not shown.

Examples/ServiceExamples/Scripts/ExampleDIalog.cs

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
using UnityEngine;
1919
using IBM.Watson.DeveloperCloud.Services.Dialog.v1;
2020

21-
public class ExampleDIalog : MonoBehaviour
21+
public class ExampleDialog : MonoBehaviour
2222
{
2323
private Dialog m_Dialog = new Dialog();
2424
private string m_DialogID = "a4015960-39c2-4d6b-9571-38c74aecfffd";
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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.DocumentConversion.v1;
20+
using System.Collections;
21+
using IBM.Watson.DeveloperCloud.Logging;
22+
23+
public class ExampleDocumentConversion : MonoBehaviour
24+
{
25+
private DocumentConversion m_DocumentConversion = new DocumentConversion();
26+
27+
void Start ()
28+
{
29+
LogSystem.InstallDefaultReactors(); LogSystem.InstallDefaultReactors();
30+
string examplePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/watson_beats_jeopardy.html";
31+
32+
if (!m_DocumentConversion.ConvertDocument(OnConvertDocument, examplePath, ConversionTarget.NORMALIZED_TEXT))
33+
Log.Debug("ExampleDocumentConversion", "Document conversion failed!");
34+
}
35+
36+
private void OnConvertDocument(ConvertedDocument documentConversionResponse, string data)
37+
{
38+
if (documentConversionResponse != null)
39+
{
40+
if(!string.IsNullOrEmpty(documentConversionResponse.media_type_detected))
41+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.media_type_detected);
42+
if (!string.IsNullOrEmpty(documentConversionResponse.source_document_id))
43+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.source_document_id);
44+
if(!string.IsNullOrEmpty(documentConversionResponse.timestamp))
45+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.timestamp);
46+
if (documentConversionResponse.metadata != null && documentConversionResponse.metadata.Length > 0)
47+
{
48+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.metadata.Length);
49+
foreach (Metadata metadata in documentConversionResponse.metadata)
50+
Log.Debug("ExampleDocumentConversion", "metadata | name: {0}, content: {1}", metadata.name, metadata.content);
51+
}
52+
if (documentConversionResponse.answer_units != null && documentConversionResponse.answer_units.Length > 0)
53+
{
54+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.answer_units.Length);
55+
foreach (AnswerUnit answerUnit in documentConversionResponse.answer_units)
56+
{
57+
Log.Debug("ExampleDocumentConversion", "answerUnit | type: {0}, title: {1}, parent_id: {2}, id: {3}, direction: {4}", answerUnit.type, answerUnit.title, answerUnit.parent_id, answerUnit.id, answerUnit.direction);
58+
if (answerUnit.content != null && answerUnit.content.Length > 0)
59+
foreach (Content content in answerUnit.content)
60+
Log.Debug("ExampleDocumentConversion", "content | mediaType: {0}, text: {1}", content.media_type, content.text);
61+
}
62+
}
63+
64+
if (!string.IsNullOrEmpty(documentConversionResponse.htmlContent))
65+
Log.Debug("ExampleDocumentConversion", "HTMLContent: {0}", documentConversionResponse.htmlContent);
66+
if (!string.IsNullOrEmpty(documentConversionResponse.textContent))
67+
Log.Debug("ExampleDocumentConversion", "TextContent: {0}", documentConversionResponse.textContent);
68+
}
69+
}
70+
}

Examples/ServiceExamples/Scripts/ExampleDocumentConversion.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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,46 @@ Transform:
332332
m_Children: []
333333
m_Father: {fileID: 0}
334334
m_RootOrder: 5
335+
--- !u!1 &1053617509
336+
GameObject:
337+
m_ObjectHideFlags: 0
338+
m_PrefabParentObject: {fileID: 0}
339+
m_PrefabInternal: {fileID: 0}
340+
serializedVersion: 4
341+
m_Component:
342+
- 4: {fileID: 1053617511}
343+
- 114: {fileID: 1053617510}
344+
m_Layer: 0
345+
m_Name: ExampleDocumentConversion
346+
m_TagString: Untagged
347+
m_Icon: {fileID: 0}
348+
m_NavMeshLayer: 0
349+
m_StaticEditorFlags: 0
350+
m_IsActive: 1
351+
--- !u!114 &1053617510
352+
MonoBehaviour:
353+
m_ObjectHideFlags: 0
354+
m_PrefabParentObject: {fileID: 0}
355+
m_PrefabInternal: {fileID: 0}
356+
m_GameObject: {fileID: 1053617509}
357+
m_Enabled: 1
358+
m_EditorHideFlags: 0
359+
m_Script: {fileID: 11500000, guid: fb388f597c08df24c887d05de5ae2ba5, type: 3}
360+
m_Name:
361+
m_EditorClassIdentifier:
362+
--- !u!4 &1053617511
363+
Transform:
364+
m_ObjectHideFlags: 0
365+
m_PrefabParentObject: {fileID: 0}
366+
m_PrefabInternal: {fileID: 0}
367+
m_GameObject: {fileID: 1053617509}
368+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
369+
m_LocalPosition: {x: 0, y: 0, z: 0}
370+
m_LocalScale: {x: 1, y: 1, z: 1}
371+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
372+
m_Children: []
373+
m_Father: {fileID: 0}
374+
m_RootOrder: 12
335375
--- !u!1 &1073418922
336376
GameObject:
337377
m_ObjectHideFlags: 0

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@ Use this SDK to build Watson-powered applications in Unity. It comes with a set
2121
* [Alchemy Language](#alchemy-language)
2222
* [AlchemyData News](#alchemy-data-news)
2323
* [Personality Insights](#personality-insights)
24+
* [Document Conversion](#document-conversion)
2425
* [Developing a basic application in one minute](#developing-a-basic-application-in-one-minute)
2526
* [Documentation](#documentation)
2627
* [License](#license)
2728
* [Contributing](#contributing)
2829

2930
## Before you begin
3031
Ensure that you have the following prerequisites:
32+
3133
* An IBM Bluemix account. If you don't have one, [sign up][bluemix_registration].
3234
* [Unity][get_unity]. You win! You can use the **free** Personal edition.
33-
* Change the build settings in Unity (**File > Build Settings**) to PC, Mac & Linux Standalone. Click PC, Mac & Linux Standalone and click the Switch Platform button.
35+
* Change the build settings in Unity (**File > Build Settings**) to any platform except for web player. The Watson Developer Cloud Unity SDK does not support Unity Web Player.
3436

3537
## Getting the Watson SDK and adding it to Unity
3638
You can get the latest SDK release by clicking [here][latest_release].
@@ -1359,6 +1361,60 @@ private void OnGetCombinedData(CombinedCallData combinedData, string data)
13591361
}
13601362
```
13611363

1364+
### Document Conversion
1365+
The IBM Watson™ [Document conversion][document_conversion] service converts a single HTML, PDF, or Microsoft Word™ document into a normalized HTML, plain text, or a set of JSON-formatted Answer units that can be used with other Watson services. Carefully inspect output to make sure that it contains all elements and metadata required by the security standards of you or your organization.
1366+
1367+
#### Converting Documents
1368+
Convert a single document
1369+
1370+
```cs
1371+
private DocumentConversion m_DocumentConversion = new DocumentConversion();
1372+
1373+
void Start ()
1374+
{
1375+
LogSystem.InstallDefaultReactors(); LogSystem.InstallDefaultReactors();
1376+
string examplePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/watson_beats_jeopardy.html";
1377+
1378+
if (!m_DocumentConversion.ConvertDocument(OnConvertDocument, examplePath, ConversionTarget.NORMALIZED_TEXT))
1379+
Log.Debug("ExampleDocumentConversion", "Document conversion failed!");
1380+
}
1381+
1382+
private void OnConvertDocument(ConvertedDocument documentConversionResponse, string data)
1383+
{
1384+
if (documentConversionResponse != null)
1385+
{
1386+
if(!string.IsNullOrEmpty(documentConversionResponse.media_type_detected))
1387+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.media_type_detected);
1388+
if (!string.IsNullOrEmpty(documentConversionResponse.source_document_id))
1389+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.source_document_id);
1390+
if(!string.IsNullOrEmpty(documentConversionResponse.timestamp))
1391+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.timestamp);
1392+
if (documentConversionResponse.metadata != null && documentConversionResponse.metadata.Length > 0)
1393+
{
1394+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.metadata.Length);
1395+
foreach (Metadata metadata in documentConversionResponse.metadata)
1396+
Log.Debug("ExampleDocumentConversion", "metadata | name: {0}, content: {1}", metadata.name, metadata.content);
1397+
}
1398+
if (documentConversionResponse.answer_units != null && documentConversionResponse.answer_units.Length > 0)
1399+
{
1400+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.answer_units.Length);
1401+
foreach (AnswerUnit answerUnit in documentConversionResponse.answer_units)
1402+
{
1403+
Log.Debug("ExampleDocumentConversion", "answerUnit | type: {0}, title: {1}, parent_id: {2}, id: {3}, direction: {4}", answerUnit.type, answerUnit.title, answerUnit.parent_id, answerUnit.id, answerUnit.direction);
1404+
if (answerUnit.content != null && answerUnit.content.Length > 0)
1405+
foreach (Content content in answerUnit.content)
1406+
Log.Debug("ExampleDocumentConversion", "content | mediaType: {0}, text: {1}", content.media_type, content.text);
1407+
}
1408+
}
1409+
1410+
if (!string.IsNullOrEmpty(documentConversionResponse.htmlContent))
1411+
Log.Debug("ExampleDocumentConversion", "HTMLContent: {0}", documentConversionResponse.htmlContent);
1412+
if (!string.IsNullOrEmpty(documentConversionResponse.textContent))
1413+
Log.Debug("ExampleDocumentConversion", "TextContent: {0}", documentConversionResponse.textContent);
1414+
}
1415+
}
1416+
```
1417+
13621418
### AlchemyData News
13631419
Use the [AlchemyData News][alchemyData_news] service to provide news and blog content enriched with natural language processing to allow for highly targeted search and trend analysis. Now you can query the world's news sources and blogs like a database.
13641420

@@ -1442,3 +1498,4 @@ See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
14421498
[visual_recognition]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/visual-recognition/api/v3/
14431499
[personality_insights]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/personality-insights/api/v2/
14441500
[conversation_tooling]: https://www.ibmwatsonconversation.com
1501+
[document_conversion]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/document-conversion/api/v1/

Scripts/Editor/ConfigEditor.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ private class ServiceSetup
6969
new ServiceSetup() { ServiceName = "Alchemy API", ServiceAPI = "gateway-a.watsonplatform.net/calls",
7070
URL ="https://console.ng.bluemix.net/catalog/services/alchemyapi/", ServiceID="AlchemyAPIV1" },
7171
new ServiceSetup() { ServiceName = "Visual Recognition", ServiceAPI = "visual-recognition/api",
72-
URL ="https://console.ng.bluemix.net/catalog/services/visual-recognition/", ServiceID="VisualRecognitionV3" }
72+
URL ="https://console.ng.bluemix.net/catalog/services/visual-recognition/", ServiceID="VisualRecognitionV3" },
73+
new ServiceSetup() { ServiceName = "Document Conversion", ServiceAPI = "document-conversion/api",
74+
URL ="https://console.ng.bluemix.net/catalog/services/document-conversion/", ServiceID="DocumentConversionV1" }
7375
};
7476

7577
private const string TITLE = "Watson Unity SDK";
@@ -96,7 +98,7 @@ private static void OnScriptsReloaded()
9698
}
9799
}
98100
}
99-
101+
100102
private void OnEnable()
101103
{
102104
#if UNITY_5
@@ -245,7 +247,7 @@ private void OnGUI()
245247
GUILayout.Label( m_StatusUnknown, GUILayout.Width( 20 ) );
246248

247249
GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
248-
labelStyle.normal.textColor = bValid ? Color.green : Color.grey;
250+
labelStyle.normal.textColor = bValid ? Color.green : Color.grey;
249251

250252
GUILayout.Label( string.Format( "Service {0} {1}.", setup.ServiceName, bValid ? "CONFIGURED" : "NOT CONFIGURED" ), labelStyle );
251253

@@ -259,7 +261,7 @@ private void OnGUI()
259261

260262
GUILayout.Label( "PASTE CREDENTIALS BELOW:" );
261263
m_PastedCredentials = EditorGUILayout.TextArea( m_PastedCredentials );
262-
264+
263265
GUI.SetNextControlName("Apply");
264266
if ( GUILayout.Button( "Apply Credentials" ) )
265267
{
@@ -281,7 +283,7 @@ private void OnGUI()
281283
{
282284
bAdd = false;
283285

284-
if ( EditorUtility.DisplayDialog( "Confirm",
286+
if ( EditorUtility.DisplayDialog( "Confirm",
285287
string.Format("Replace existing service credentials for {0}?", setup.ServiceName),
286288
YES, NO ) )
287289
{
@@ -301,7 +303,7 @@ private void OnGUI()
301303
if ( bParsed )
302304
{
303305
m_CheckServicesNow = true;
304-
306+
305307
EditorUtility.DisplayDialog( "Complete", "Credentials applied.", OK );
306308
m_PastedCredentials = "\n\n\n\n\n\n\n";
307309
GUI.FocusControl("Apply");
@@ -320,7 +322,7 @@ private void OnGUI()
320322
m_WizardMode = false;
321323
PlayerPrefs.SetInt( "WizardMode", 0 );
322324
}
323-
}
325+
}
324326
else
325327
{
326328
cfg.ClassifierDirectory = EditorGUILayout.TextField("Classifier Directory", cfg.ClassifierDirectory );

Scripts/Services/DocumentConversion.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)