Skip to content

Commit e40ec1e

Browse files
committed
chore(PI): Generate personality insights
1 parent 81384c7 commit e40ec1e

File tree

1 file changed

+44
-38
lines changed

1 file changed

+44
-38
lines changed

watson_developer_cloud/personality_insights_v3.py

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
timestamped, can report temporal behavior.
2626
* For information about the meaning of the models that the service uses to describe
2727
personality characteristics, see [Personality
28-
models](https://console.bluemix.net/docs/services/personality-insights/models.html).
28+
models](/docs/services/personality-insights/models.html).
2929
* For information about the meaning of the consumption preferences, see [Consumption
30-
preferences](https://console.bluemix.net/docs/services/personality-insights/preferences.html).
31-
**Note:** Request logging is disabled for the Personality Insights service. The service
32-
neither logs nor retains data from requests and responses, regardless of whether the
33-
`X-Watson-Learning-Opt-Out` request header is set.
30+
preferences](/docs/services/personality-insights/preferences.html).
31+
**Note:** Request logging is disabled for the Personality Insights service. Regardless of
32+
whether you set the `X-Watson-Learning-Opt-Out` request header, the service does not log
33+
or retain data from requests and responses.
3434
"""
3535

3636
from __future__ import absolute_import
@@ -119,8 +119,8 @@ def __init__(
119119

120120
def profile(self,
121121
content,
122-
content_type,
123-
accept=None,
122+
accept,
123+
content_type=None,
124124
content_language=None,
125125
accept_language=None,
126126
raw_scores=None,
@@ -132,38 +132,44 @@ def profile(self,
132132

133133
Generates a personality profile for the author of the input text. The service
134134
accepts a maximum of 20 MB of input content, but it requires much less text to
135-
produce an accurate profile; for more information, see [Providing sufficient
136-
input](https://console.bluemix.net/docs/services/personality-insights/input.html#sufficient).
137-
The service analyzes text in Arabic, English, Japanese, Korean, or Spanish and
138-
returns its results in a variety of languages. You can provide plain text, HTML,
139-
or JSON input by specifying the **Content-Type** parameter; the default is
140-
`text/plain`. Request a JSON or comma-separated values (CSV) response by
141-
specifying the **Accept** parameter; CSV output includes a fixed number of columns
142-
and optional headers.
143-
Per the JSON specification, the default character encoding for JSON content is
144-
effectively always UTF-8; per the HTTP specification, the default encoding for
145-
plain text and HTML is ISO-8859-1 (effectively, the ASCII character set). When
146-
specifying a content type of plain text or HTML, include the `charset` parameter
147-
to indicate the character encoding of the input text; for example: `Content-Type:
148-
text/plain;charset=utf-8`.
135+
produce an accurate profile. The service can analyze text in Arabic, English,
136+
Japanese, Korean, or Spanish. It can return its results in a variety of languages.
149137
**See also:**
150-
* [Requesting a
151-
profile](https://console.bluemix.net/docs/services/personality-insights/input.html)
152-
* [Understanding a JSON
153-
profile](https://console.bluemix.net/docs/services/personality-insights/output.html)
138+
* [Requesting a profile](/docs/services/personality-insights/input.html)
139+
* [Providing sufficient
140+
input](/docs/services/personality-insights/input.html#sufficient)
141+
### Content types
142+
You can provide input content as plain text (`text/plain`), HTML (`text/html`),
143+
or JSON (`application/json`) by specifying the **Content-Type** parameter. The
144+
default is `text/plain`.
145+
* Per the JSON specification, the default character encoding for JSON content is
146+
effectively always UTF-8.
147+
* Per the HTTP specification, the default encoding for plain text and HTML is
148+
ISO-8859-1 (effectively, the ASCII character set).
149+
When specifying a content type of plain text or HTML, include the `charset`
150+
parameter to indicate the character encoding of the input text; for example,
151+
`Content-Type: text/plain;charset=utf-8`.
152+
**See also:** [Specifying request and response
153+
formats](/docs/services/personality-insights/input.html#formats)
154+
### Accept types
155+
You must request a response as JSON (`application/json`) or comma-separated
156+
values (`text/csv`) by specifying the **Accept** parameter. CSV output includes a
157+
fixed number of columns. Set the **csv_headers** parameter to `true` to request
158+
optional column headers for CSV output.
159+
**See also:**
160+
* [Understanding a JSON profile](/docs/services/personality-insights/output.html)
154161
* [Understanding a CSV
155-
profile](https://console.bluemix.net/docs/services/personality-insights/output-csv.html).
162+
profile](/docs/services/personality-insights/output-csv.html).
156163

157164
:param Content content: A maximum of 20 MB of content to analyze, though the
158165
service requires much less text; for more information, see [Providing sufficient
159-
input](https://console.bluemix.net/docs/services/personality-insights/input.html#sufficient).
160-
For JSON input, provide an object of type `Content`.
161-
:param str content_type: The type of the input. A character encoding can be
162-
specified by including a `charset` parameter. For example,
163-
'text/html;charset=utf-8'.
164-
:param str accept: The type of the response: application/json or text/csv. A
165-
character encoding can be specified by including a `charset` parameter. For
166-
example, 'text/csv;charset=utf-8'.
166+
input](/docs/services/personality-insights/input.html#sufficient). For JSON input,
167+
provide an object of type `Content`.
168+
:param str accept: The type of the response. For more information, see **Accept
169+
types** in the method description.
170+
:param str content_type: The type of the input. For more information, see
171+
**Content types** in the method description.
172+
Default: `text/plain`.
167173
:param str content_language: The language of the input text for the request:
168174
Arabic, English, Japanese, Korean, or Spanish. Regional variants are treated as
169175
their parent language; for example, `en-US` is interpreted as `en`.
@@ -184,7 +190,7 @@ def profile(self,
184190
sample population. By default, only normalized percentiles are returned.
185191
:param bool csv_headers: Indicates whether column labels are returned with a CSV
186192
response. By default, no column labels are returned. Applies only when the
187-
**Accept** parameter is set to `text/csv`.
193+
response type is CSV (`text/csv`).
188194
:param bool consumption_preferences: Indicates whether consumption preferences are
189195
returned with the results. By default, no consumption preferences are returned.
190196
:param dict headers: A `dict` containing the request headers
@@ -194,14 +200,14 @@ def profile(self,
194200

195201
if content is None:
196202
raise ValueError('content must be provided')
197-
if content_type is None:
198-
raise ValueError('content_type must be provided')
203+
if accept is None:
204+
raise ValueError('accept must be provided')
199205
if isinstance(content, Content):
200206
content = self._convert_model(content, Content)
201207

202208
headers = {
203-
'Content-Type': content_type,
204209
'Accept': accept,
210+
'Content-Type': content_type,
205211
'Content-Language': content_language,
206212
'Accept-Language': accept_language
207213
}

0 commit comments

Comments
 (0)