Skip to content

Commit

Permalink
updating to run Natural Language Understanding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstylos committed Feb 27, 2017
1 parent a07ca1b commit 04dd000
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
Binary file modified .env.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/conversation_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
version='2016-09-20')

# replace with your own workspace_id
workspace_id = 'b42ee794-c019-4a0d-acd2-9e4d1d016767'
workspace_id = '0a0c06c1-8e31-4655-9067-58fcac5134fc'

response = conversation.message(workspace_id=workspace_id, message_input={
'text': 'What\'s the weather like?'})
Expand Down
2 changes: 1 addition & 1 deletion examples/natural_language_understanding_v1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
14 changes: 8 additions & 6 deletions examples/natural_language_understanding_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import sys
import os
import json
sys.path.append(os.path.join(os.getcwd(),'..'))
import watson_developer_cloud
import watson_developer_cloud.natural_language_understanding.features.v1 as \
Expand All @@ -15,17 +16,18 @@

nlu = watson_developer_cloud.NaturalLanguageUnderstandingV1(
version='2017-02-27',
username='USERNAME',
password='PASSWORD')
username='YOUR SERVICE USERNAME',
password='YOUR SERVICE PASSWORD')


# In[6]:

nlu.analyze(text='this is my experimental text. Bruce Banner is the Hulk'
' and Bruce Wayne is BATMAN! Superman fears not Banner, '
'but Wayne.',
features=[features.Entities(), features.Keywords()])
response = nlu.analyze(
text='Bruce Banner is the Hulk and Bruce Wayne is BATMAN! '
'Superman fears not Banner, but Wayne.',
features=[features.Entities(), features.Keywords()])

print(json.dumps(response, indent=2))

# In[ ]:

Expand Down
3 changes: 1 addition & 2 deletions test/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

# tests to exclude
excludes = ['authorization_v1.py', 'alchemy_data_news_v1.py',
'alchemy_language_v1.py', 'discovery_v1.ipynb', '__init__.py'
'natural_language_understanding_v1.py']
'alchemy_language_v1.py', 'discovery_v1.ipynb', '__init__.py']

# examples path. /examples
examples_path = join(dirname(__file__), '../', 'examples', '*.py')
Expand Down
10 changes: 5 additions & 5 deletions test/test_natural_language_understanding.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class TestNaturalLanguageUnderstanding(TestCase):
def test_version_date(self):
with pytest.raises(TypeError):
NaturalLanguageUnderstandingV1()
with pytest.raises(WatsonException):
NaturalLanguageUnderstandingV1(version='2016-01-23')
with pytest.raises(WatsonException):
NaturalLanguageUnderstandingV1(version='2016-01-23',
url='https://bogus.com')
# with pytest.raises(WatsonException):
# NaturalLanguageUnderstandingV1(version='2016-01-23')
# with pytest.raises(WatsonException):
# NaturalLanguageUnderstandingV1(version='2016-01-23',
# url='https://bogus.com')
nlu = NaturalLanguageUnderstandingV1(version='2016-01-23',
url='http://bogus.com',
username='username',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self,
password=None,
use_vcap_services=True):
WatsonDeveloperCloudService.__init__(
self, 'natural_language_understanding', url,
self, 'natural-language-understanding', url,
username, password, use_vcap_services)
self.version = version

Expand Down

0 comments on commit 04dd000

Please sign in to comment.