Skip to content

Commit 8dc6c95

Browse files
committed
moving to 80 char lines
1 parent 5a4a059 commit 8dc6c95

41 files changed

Lines changed: 1122 additions & 619 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2015 IBM All Rights Reserved.
1+
# Copyright 2016 IBM All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

examples/alchemy_data_news_v1.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
alchemy_data_news = AlchemyDataNewsV1(api_key='YOUR API KEY')
55

6-
results = alchemy_data_news.get_news_documents(start='now-7d', end='now', time_slice='12h')
6+
results = alchemy_data_news.get_news_documents(start='now-7d', end='now',
7+
time_slice='12h')
78
print(json.dumps(results, indent=2))
89

910
results = alchemy_data_news.get_news_documents(
@@ -13,5 +14,7 @@
1314
'enriched.url.url',
1415
'enriched.url.author',
1516
'enriched.url.publicationDate'],
16-
query_fields={'q.enriched.url.enrichedTitle.entities.entity': '|text=IBM,type=company|'})
17+
query_fields={
18+
'q.enriched.url.enrichedTitle.entities.entity':
19+
'|text=IBM,type=company|'})
1720
print(json.dumps(results, indent=2))

examples/alchemy_language_v1.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@
44

55
alchemy_language = AlchemyLanguageV1(api_key='YOUR API KEY')
66

7-
url = 'https://developer.ibm.com/watson/blog/2015/11/03/price-reduction-for-watson-personality-insights/'
7+
url = 'https://developer.ibm.com/watson/blog/2015/11/03/price-reduction-for' \
8+
'-watson-personality-insights/'
89

9-
print(json.dumps(alchemy_language.targeted_sentiment(text='I love cats! Dogs are smelly.',
10-
targets=['cats', 'dogs'], language='english'), indent=2))
11-
# print(json.dumps(alchemy_language.targeted_emotion(text='I love apples. I hate bananas',
12-
# targets=['apples', 'bananas'], language='english'), indent=2))
10+
print(json.dumps(
11+
alchemy_language.targeted_sentiment(text='I love cats! Dogs are smelly.',
12+
targets=['cats', 'dogs'],
13+
language='english'), indent=2))
14+
# print(json.dumps(alchemy_language.targeted_emotion(text='I love apples. I
15+
# hate bananas',
16+
# targets=['apples',
17+
# 'bananas'], language='english'), indent=2))
1318

1419
# print(json.dumps(alchemy_language.author(url=url), indent=2))
1520
# print(json.dumps(alchemy_language.concepts(max_items=2, url=url), indent=2))
16-
# print(json.dumps(alchemy_language.dates(url=url, anchor_date='2016-03-22 00:00:00'), indent=2))
21+
# print(json.dumps(alchemy_language.dates(url=url, anchor_date='2016-03-22
22+
# 00:00:00'), indent=2))
1723
# print(json.dumps(alchemy_language.emotion(url=url), indent=2))
1824
# print(json.dumps(alchemy_language.entities(url=url), indent=2))
1925
# print(json.dumps(alchemy_language.keywords(max_items=5, url=url), indent=2))
@@ -25,12 +31,19 @@
2531
# print(json.dumps(alchemy_language.raw_text(url=url), indent=2))
2632
# print(json.dumps(alchemy_language.title(url=url), indent=2))
2733
# print(json.dumps(alchemy_language.feeds(url=url), indent=2))
28-
# print(json.dumps(alchemy_language.microformats(url='http://microformats.org/wiki/hcard-examples'), indent=2))
34+
# print(json.dumps(alchemy_language.microformats(
35+
# url='http://microformats.org/wiki/hcard-examples'), indent=2))
2936
# print(json.dumps(alchemy_language.publication_date(url=url), indent=2))
3037
# print(json.dumps(alchemy_language.taxonomy(url=url), indent=2))
31-
combined_operations = ['page-image', 'entity', 'keyword', 'title', 'author', 'taxonomy', 'concept', 'doc-emotion']
32-
print(json.dumps(alchemy_language.combined(url=url, extract=combined_operations), indent=2))
38+
combined_operations = ['page-image', 'entity', 'keyword', 'title', 'author',
39+
'taxonomy', 'concept', 'doc-emotion']
40+
print(
41+
json.dumps(alchemy_language.combined(url=url, extract=combined_operations),
42+
indent=2))
3343

3444
# Get sentiment and emotion information results for detected entities/keywords:
35-
# print(json.dumps(alchemy_language.entities(url=url, sentiment=True, emotion=True), indent=2))
36-
# print(json.dumps(alchemy_language.keywords(max_items=5, url=url, sentiment=True, emotion=True), indent=2))
45+
# print(json.dumps(alchemy_language.entities(url=url, sentiment=True,
46+
# emotion=True), indent=2))
47+
# print(json.dumps(alchemy_language.keywords(max_items=5, url=url,
48+
# sentiment=True, emotion=True),
49+
# indent=2))

examples/authorization_v1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
username='YOUR SERVICE USERNAME',
77
password='YOUR SERVICE PASSWORD')
88

9-
print(json.dumps(authorization.get_token(url=SpeechToTextV1.default_url), indent=2))
9+
print(json.dumps(authorization.get_token(url=SpeechToTextV1.default_url),
10+
indent=2))

examples/conversation_tone_analyzer_integration/tone_conversation_integration.v1.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
# import tone detection
99
import tone_detection
1010

11-
# load the .env file containing your environment variables for the required services (conversation and tone)
11+
# load the .env file containing your environment variables for the required
12+
# services (conversation and tone)
1213
load_dotenv(find_dotenv())
1314

1415
# replace with your own conversation credentials or put them in a .env file
@@ -33,29 +34,37 @@
3334
# Payload for the Watson Conversation Service
3435
# user input text required - replace "I am happy" with user input text.
3536
payload = {
36-
'workspace_id':workspace_id,
37+
'workspace_id': workspace_id,
3738
'input': {
38-
'text': "I am happy"
39+
'text': "I am happy"
3940
}
4041
}
4142

42-
def invokeToneConversation (payload, maintainToneHistoryInContext):
43-
'''
44-
invokeToneConversation calls the the Tone Analyzer service to get the tone information for the user's
45-
input text (input['text'] in the payload json object), adds/updates the user's tone in the payload's context,
46-
and sends the payload to the conversation service to get a response which is printed to screen.
47-
:param payload: a json object containing the basic information needed to converse with the Conversation Service's message endpoint.
43+
44+
def invokeToneConversation(payload, maintainToneHistoryInContext):
45+
"""
46+
invokeToneConversation calls the the Tone Analyzer service to get the
47+
tone information for the user's input text (input['text'] in the payload
48+
json object), adds/updates the user's tone in the payload's context,
49+
and sends the payload to the
50+
conversation service to get a response which is printed to screen.
51+
:param payload: a json object containing the basic information needed to
52+
converse with the Conversation Service's message endpoint.
4853
:param maintainHistoryInContext:
4954
5055
51-
Note: as indicated below, the console.log statements can be replaced with application-specific code to process the err or data object returned by the Conversation Service.
52-
'''
56+
Note: as indicated below, the console.log statements can be replaced
57+
with application-specific code to process the err or data object
58+
returned by the Conversation Service.
59+
"""
5360
tone = tone_analyzer.tone(text=payload['input']['text'])
54-
conversation_payload = tone_detection.updateUserTone(payload, tone, maintainToneHistoryInContext)
55-
response = conversation.message(workspace_id=workspace_id, message_input=conversation_payload['input'], context=conversation_payload['context'])
61+
conversation_payload = tone_detection.\
62+
updateUserTone(payload, tone, maintainToneHistoryInContext)
63+
response = conversation.message(workspace_id=workspace_id,
64+
message_input=conversation_payload['input'],
65+
context=conversation_payload['context'])
5666
print(json.dumps(response, indent=2))
5767

58-
# synchronous call to conversation with tone included in the context
59-
invokeToneConversation(payload,maintainToneHistoryInContext)
60-
6168

69+
# synchronous call to conversation with tone included in the context
70+
invokeToneConversation(payload, maintainToneHistoryInContext)

0 commit comments

Comments
 (0)