Skip to content

Commit d5d3499

Browse files
authored
Merge branch 'develop' into gh-213-emptyDialogStack
2 parents 00410fa + e532dc3 commit d5d3499

19 files changed

+1501
-23
lines changed

.editorconfig

Lines changed: 0 additions & 11 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Change Log
22
==========
3+
## Version 0.14.0
4+
_2017-07-xx_
5+
* New: Abstracted `Natural Language Understanding` service.
6+
37
## Version 0.13.0
48
_2017-01-25_
59

Config.json.enc

496 Bytes
Binary file not shown.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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 FullSerializer;
19+
using IBM.Watson.DeveloperCloud.Logging;
20+
using IBM.Watson.DeveloperCloud.Services.NaturalLanguageUnderstanding.v1;
21+
using UnityEngine;
22+
23+
public class ExampleNaturalLanguageUnderstandingV1 : MonoBehaviour
24+
{
25+
NaturalLanguageUnderstanding m_NaturalLanguageUnderstanding = new NaturalLanguageUnderstanding();
26+
private static fsSerializer sm_Serializer = new fsSerializer();
27+
28+
void Start ()
29+
{
30+
LogSystem.InstallDefaultReactors();
31+
32+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "attempting to get models...");
33+
if (!m_NaturalLanguageUnderstanding.GetModels(OnGetModels))
34+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "Failed to get models.");
35+
36+
Parameters parameters = new Parameters()
37+
{
38+
text = "Analyze various features of text content at scale. Provide text, raw HTML, or a public URL, and IBM Watson Natural Language Understanding will give you results for the features you request. The service cleans HTML content before analysis by default, so the results can ignore most advertisements and other unwanted content.",
39+
return_analyzed_text = true,
40+
language = "en",
41+
features = new Features()
42+
{
43+
entities = new EntitiesOptions()
44+
{
45+
limit = 50,
46+
sentiment = true,
47+
emotion = true,
48+
},
49+
keywords = new KeywordsOptions()
50+
{
51+
limit = 50,
52+
sentiment = true,
53+
emotion = true
54+
}
55+
}
56+
};
57+
58+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "attempting to analyze...");
59+
if (!m_NaturalLanguageUnderstanding.Analyze(OnAnalyze, parameters))
60+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "Failed to get models.");
61+
}
62+
63+
private void OnGetModels(ListModelsResults resp, string customData)
64+
{
65+
fsData data = null;
66+
sm_Serializer.TrySerialize(resp, out data).AssertSuccess();
67+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "ListModelsResult: {0}", data.ToString());
68+
}
69+
70+
private void OnAnalyze(AnalysisResults resp, string customData)
71+
{
72+
fsData data = null;
73+
sm_Serializer.TrySerialize(resp, out data).AssertSuccess();
74+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "AnalysisResults: {0}", data.ToString());
75+
}
76+
}

Examples/ServiceExamples/Scripts/ExampleNaturalLanguageUnderstandingV1.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: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ OcclusionCullingSettings:
1313
--- !u!104 &2
1414
RenderSettings:
1515
m_ObjectHideFlags: 0
16-
serializedVersion: 7
16+
serializedVersion: 8
1717
m_Fog: 0
1818
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
1919
m_FogMode: 3
@@ -25,6 +25,7 @@ RenderSettings:
2525
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
2626
m_AmbientIntensity: 1
2727
m_AmbientMode: 0
28+
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
2829
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
2930
m_HaloStrength: 0.5
3031
m_FlareStrength: 1
@@ -41,7 +42,7 @@ RenderSettings:
4142
--- !u!157 &3
4243
LightmapSettings:
4344
m_ObjectHideFlags: 0
44-
serializedVersion: 7
45+
serializedVersion: 9
4546
m_GIWorkflowMode: 0
4647
m_GISettings:
4748
serializedVersion: 2
@@ -53,7 +54,7 @@ LightmapSettings:
5354
m_EnableBakedLightmaps: 1
5455
m_EnableRealtimeLightmaps: 1
5556
m_LightmapEditorSettings:
56-
serializedVersion: 4
57+
serializedVersion: 8
5758
m_Resolution: 2
5859
m_BakeResolution: 40
5960
m_TextureWidth: 1024
@@ -66,13 +67,27 @@ LightmapSettings:
6667
m_LightmapParameters: {fileID: 0}
6768
m_LightmapsBakeMode: 1
6869
m_TextureCompression: 1
69-
m_DirectLightInLightProbes: 1
7070
m_FinalGather: 0
7171
m_FinalGatherFiltering: 1
7272
m_FinalGatherRayCount: 1024
7373
m_ReflectionCompression: 2
74+
m_MixedBakeMode: 1
75+
m_BakeBackend: 0
76+
m_PVRSampling: 1
77+
m_PVRDirectSampleCount: 32
78+
m_PVRSampleCount: 500
79+
m_PVRBounces: 2
80+
m_PVRFiltering: 0
81+
m_PVRFilteringMode: 1
82+
m_PVRCulling: 1
83+
m_PVRFilteringGaussRadiusDirect: 1
84+
m_PVRFilteringGaussRadiusIndirect: 5
85+
m_PVRFilteringGaussRadiusAO: 2
86+
m_PVRFilteringAtrousColorSigma: 1
87+
m_PVRFilteringAtrousNormalSigma: 1
88+
m_PVRFilteringAtrousPositionSigma: 1
7489
m_LightingDataAsset: {fileID: 0}
75-
m_RuntimeCPUUsage: 25
90+
m_ShadowMaskMode: 2
7691
--- !u!196 &4
7792
NavMeshSettings:
7893
serializedVersion: 2
@@ -89,6 +104,8 @@ NavMeshSettings:
89104
minRegionArea: 2
90105
manualCellSize: 0
91106
cellSize: 0.16666667
107+
manualTileSize: 0
108+
tileSize: 256
92109
accuratePlacement: 0
93110
m_NavMeshData: {fileID: 0}
94111
--- !u!1 &85803340
@@ -321,6 +338,8 @@ Camera:
321338
m_TargetDisplay: 0
322339
m_TargetEye: 3
323340
m_HDR: 0
341+
m_AllowMSAA: 1
342+
m_ForceIntoRT: 0
324343
m_OcclusionCulling: 1
325344
m_StereoConvergence: 10
326345
m_StereoSeparation: 0.022
@@ -659,6 +678,46 @@ Transform:
659678
m_Father: {fileID: 0}
660679
m_RootOrder: 14
661680
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
681+
--- !u!1 &1646373635
682+
GameObject:
683+
m_ObjectHideFlags: 0
684+
m_PrefabParentObject: {fileID: 0}
685+
m_PrefabInternal: {fileID: 0}
686+
serializedVersion: 5
687+
m_Component:
688+
- component: {fileID: 1646373637}
689+
- component: {fileID: 1646373636}
690+
m_Layer: 0
691+
m_Name: ExampleNaturalLanguageUnderstandingV1
692+
m_TagString: Untagged
693+
m_Icon: {fileID: 0}
694+
m_NavMeshLayer: 0
695+
m_StaticEditorFlags: 0
696+
m_IsActive: 1
697+
--- !u!114 &1646373636
698+
MonoBehaviour:
699+
m_ObjectHideFlags: 0
700+
m_PrefabParentObject: {fileID: 0}
701+
m_PrefabInternal: {fileID: 0}
702+
m_GameObject: {fileID: 1646373635}
703+
m_Enabled: 1
704+
m_EditorHideFlags: 0
705+
m_Script: {fileID: 11500000, guid: a2bd480466fdc154fa059d91ab9b79a8, type: 3}
706+
m_Name:
707+
m_EditorClassIdentifier:
708+
--- !u!4 &1646373637
709+
Transform:
710+
m_ObjectHideFlags: 0
711+
m_PrefabParentObject: {fileID: 0}
712+
m_PrefabInternal: {fileID: 0}
713+
m_GameObject: {fileID: 1646373635}
714+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
715+
m_LocalPosition: {x: 134.92715, y: 220.47162, z: 32.101807}
716+
m_LocalScale: {x: 1, y: 1, z: 1}
717+
m_Children: []
718+
m_Father: {fileID: 0}
719+
m_RootOrder: 16
720+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
662721
--- !u!1 &1713392457
663722
GameObject:
664723
m_ObjectHideFlags: 0

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Use this SDK to build Watson-powered applications in Unity. It comes with a set
2424
* [AlchemyData News](#alchemy-data-news)
2525
* [Retrieve and Rank](#retrieve-and-rank)
2626
* [Discovery](#discovery)
27+
* [Natural Language Understanding](#natural-language-understanding)
2728
* [Developing a basic application in one minute](#developing-a-basic-application-in-one-minute)
2829
* [Documentation](#documentation)
2930
* [License](#license)
@@ -2814,6 +2815,94 @@ private void OnQuery(QueryResponse resp, string data)
28142815
Log.Debug("ExampleDiscoveryV1", "resp is null, {0}", data);
28152816
}
28162817
```
2818+
### Natural Language Understanding
2819+
[Natural Language Understanding][natural_language_understanding] uses natural language processing to analyze semantic features of any text. Provide plain text, HTML, or a public URL, and Natural Language Understanding returns results for the features you specify. The service cleans HTML before analysis by default, which removes most advertisements and other unwanted content.
2820+
2821+
You can create [custom models][nlu_models] with Watson Knowledge Studio that can be used to detect custom [entities][nlu_entities] and [relations][nlu_relations] in Natural Language Understanding.
2822+
2823+
#### Analyze
2824+
Analyze features of natural language content.
2825+
2826+
```cs
2827+
NaturalLanguageUnderstanding m_NaturalLanguageUnderstanding = new NaturalLanguageUnderstanding();
2828+
private static fsSerializer sm_Serializer = new fsSerializer();
2829+
2830+
void Start ()
2831+
{
2832+
Parameters parameters = new Parameters()
2833+
{
2834+
text = <text-to-analyze>,
2835+
return_analyzed_text = true,
2836+
language = "en",
2837+
features = new Features()
2838+
{
2839+
entities = new EntitiesOptions()
2840+
{
2841+
limit = 50,
2842+
sentiment = true,
2843+
emotion = true,
2844+
},
2845+
keywords = new KeywordsOptions()
2846+
{
2847+
limit = 50,
2848+
sentiment = true,
2849+
emotion = true
2850+
}
2851+
}
2852+
};
2853+
2854+
if (!m_NaturalLanguageUnderstanding.Analyze(OnAnalyze, parameters))
2855+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "Failed to get models.");
2856+
}
2857+
2858+
private void OnAnalyze(AnalysisResults resp, string customData)
2859+
{
2860+
fsData data = null;
2861+
sm_Serializer.TrySerialize(resp, out data).AssertSuccess();
2862+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "AnalysisResults: {0}", data.ToString());
2863+
}
2864+
```
2865+
2866+
#### Get models
2867+
List available custom models.
2868+
2869+
```cs
2870+
NaturalLanguageUnderstanding m_NaturalLanguageUnderstanding = new NaturalLanguageUnderstanding();
2871+
private static fsSerializer sm_Serializer = new fsSerializer();
2872+
2873+
void Start ()
2874+
{
2875+
if (!m_NaturalLanguageUnderstanding.GetModels(OnGetModels))
2876+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "Failed to get models.");
2877+
}
2878+
2879+
private void OnGetModels(ListModelsResults resp, string customData)
2880+
{
2881+
fsData data = null;
2882+
sm_Serializer.TrySerialize(resp, out data).AssertSuccess();
2883+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "ListModelsResult: {0}", data.ToString());
2884+
}
2885+
```
2886+
2887+
#### Delete model
2888+
Delete a custom model.
2889+
2890+
```cs
2891+
NaturalLanguageUnderstanding m_NaturalLanguageUnderstanding = new NaturalLanguageUnderstanding();
2892+
private static fsSerializer sm_Serializer = new fsSerializer();
2893+
2894+
void Start ()
2895+
{
2896+
if (!m_NaturalLanguageUnderstanding.DeleteModel(OnDeleteModel, <model-id>))
2897+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "Failed to delete model.");
2898+
}
2899+
2900+
private void OnDeleteModel(bool success, string customData)
2901+
{
2902+
Log.Debug("ExampleNaturalLanguageUnderstandingV1", "DeleteModelResult: {0}", success);
2903+
}
2904+
```
2905+
28172906

28182907
## Developing a basic application in one minute
28192908
You can quickly develop a basic application that uses the Speech to Text service and the Natural Language Classifier service by using the prefabs that come with the SDK. Ensure that you prepare the test data before you complete the the following steps:
@@ -2876,6 +2965,10 @@ See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
28762965
[expressive_ssml]: http://www.ibm.com/watson/developercloud/doc/text-to-speech/http.shtml#expressive
28772966
[ssml]: http://www.ibm.com/watson/developercloud/doc/text-to-speech/SSML.shtml
28782967
[discovery-query]: http://www.ibm.com/watson/developercloud/doc/discovery/using.shtml
2968+
[natural_language_understanding]: https://www.ibm.com/watson/developercloud/natural-language-understanding.html
2969+
[nlu_models]: https://www.ibm.com/watson/developercloud/doc/natural-language-understanding/customizing.html
2970+
[nlu_entities]: https://www.ibm.com/watson/developercloud/natural-language-understanding/api/v1/#entities
2971+
[nlu_relations]: https://www.ibm.com/watson/developercloud/natural-language-understanding/api/v1/#relations
28792972

28802973
[dialog_service]: http://www.ibm.com/watson/developercloud/doc/dialog/
28812974
[dialog_migration]: https://www.ibm.com/watson/developercloud/doc/conversation/migration.shtml

Scripts/Services/Discovery/v1/DataModels.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ public class DiskUsage
9898
/// <summary>
9999
/// Number of bytes used on the environment's disk capacity.
100100
/// </summary>
101-
public uint used_bytes { get; set; }
101+
public long used_bytes { get; set; }
102102
/// <summary>
103103
/// Total number of bytes available in the environment's disk capacity.
104104
/// </summary>
105-
public uint total_bytes { get; set; }
105+
public long total_bytes { get; set; }
106106
/// <summary>
107107
/// Amount of disk capacity used, in KB or GB format.
108108
/// </summary>
@@ -126,11 +126,11 @@ public class MemoryUsage
126126
/// <summary>
127127
/// Number of bytes used in the environment's memory capacity.
128128
/// </summary>
129-
public uint used_bytes { get; set; }
129+
public long used_bytes { get; set; }
130130
/// <summary>
131131
/// Total number of bytes available in the environment's memory capacity.
132132
/// </summary>
133-
public uint total_bytes { get; set; }
133+
public long total_bytes { get; set; }
134134
/// <summary>
135135
/// Amount of memory capacity used, in KB or GB format.
136136
/// </summary>

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