|
1 | | -import json |
2 | | -import watson_developer_cloud |
3 | | - |
4 | | - |
5 | | -personality_insights = watson_developer_cloud.PersonalityInsightsV2() |
6 | | - |
7 | | -with open('../resources/personality.txt') as personality_text: |
8 | | - print(json.dumps(personality_insights.profile(text=personality_text.read()), indent=2)) |
9 | | - |
10 | | -# with open('../resources/personality.txt') as personality_text: |
11 | | -# personality_insights_json = {"contentItems": [ |
12 | | -# {"id": "245160944223793152", "userid": "bob", "sourceid": "twitter", "created": 1427720427, |
13 | | -# "updated": 1427720427, "contenttype": "text/plain", "charset": "UTF-8", "language": "en-us", |
14 | | -# "content": personality_text.read(), "parentid": "", "reply": "false", "forward": "false"}]} |
15 | | -# print(json.dumps(personality_insights.profile(text=personality_insights_json), indent=2)) |
16 | | - |
17 | | -# with open('../resources/personality.es.txt') as personality_text: |
18 | | -# print(json.dumps(personality_insights.profile(text=personality_text.read(), language='es'), indent=2)) |
| 1 | +import json |
| 2 | +import watson_developer_cloud.PersonalityInsightsV2 as PersonalityInsights |
| 3 | + |
| 4 | + |
| 5 | +personality_insights = PersonalityInsights(username='YOUR SERVICE USERNAME', |
| 6 | + password='YOUR SERVICE PASSWORD') |
| 7 | + |
| 8 | +with open('../resources/personality.txt') as personality_text: |
| 9 | + print(json.dumps(personality_insights.profile( |
| 10 | + text=personality_text.read()), indent=2)) |
| 11 | + |
| 12 | + |
| 13 | +# with open('../resources/personality.txt') as personality_text: |
| 14 | +# personality_insights_json = {"contentItems": [ |
| 15 | +# {"id": "245160944223793152", "userid": "bob", "sourceid": "twitter", "created": 1427720427, |
| 16 | +# "updated": 1427720427, "contenttype": "text/plain", "charset": "UTF-8", "language": "en-us", |
| 17 | +# "content": personality_text.read(), "parentid": "", "reply": "false", "forward": "false"}]} |
| 18 | +# print(json.dumps(personality_insights.profile(text=personality_insights_json), indent=2)) |
| 19 | + |
| 20 | +# with open('../resources/personality.es.txt') as personality_text: |
| 21 | +# print(json.dumps(personality_insights.profile(text=personality_text.read(), language='es'), indent=2)) |
0 commit comments