watson_developer_cloud.personality_insights_v3 module

### Service Overview The IBM Watson Personality Insights service provides a Representational State Transfer (REST) Application Programming Interface (API) that enables applications to derive insights from social media, enterprise data, or other digital communications. The service uses linguistic analytics to infer individuals’ intrinsic personality characteristics, including Big Five, Needs, and Values, from digital communications such as email, text messages, tweets, and forum posts. The service can automatically infer, from potentially noisy social media, portraits of individuals that reflect their personality characteristics. The service can report consumption preferences based on the results of its analysis, and for JSON content that is timestamped, it can report temporal behavior. ### API Usage The following information provides details about using the service to obtain a personality profile: * The profile method: The service offers a single /v3/profile method that accepts up to 20 MB of input data and produces results in JSON or CSV format. The service accepts input in Arabic, English, Japanese, Korean, or Spanish and can produce output in a variety of languages. * Authentication: You authenticate to the service by using your service credentials. You can use your credentials to authenticate via a proxy server that resides in Bluemix, or you can use your credentials to obtain a token and contact the service directly. See [Service credentials for Watson services](https://console.bluemix.net/docs/services/watson/getting-started-credentials.html) and [Tokens for authentication](https://console.bluemix.net/docs/services/watson/getting-started-tokens.html). * Request Logging: By default, all Watson services log requests and their results. Data is collected only to improve the Watson services. If you do not want to share your data, set the header parameter X-Watson-Learning-Opt-Out to true for each request. Data is collected for any request that omits this header. See [Controlling request logging for Watson services](https://console.bluemix.net/docs/services/watson/getting-started-logging.html).

For more information about the service, see [About Personality Insights](https://console.bluemix.net/docs/services/personality-insights/index.html). For information about calling the service and the responses it can generate, see [Requesting a profile](https://console.bluemix.net/docs/services/personality-insights/input.html), [Understanding a JSON profile](https://console.bluemix.net/docs/services/personality-insights/output.html), and [Understanding a CSV profile](https://console.bluemix.net/docs/services/personality-insights/output-csv.html).

class PersonalityInsightsV3(version, url='https://gateway.watsonplatform.net/personality-insights/api', username=None, password=None)[source]

Bases: watson_developer_cloud.watson_service.WatsonService

The Personality Insights V3 service.

default_url = 'https://gateway.watsonplatform.net/personality-insights/api'
profile(content, content_type='application/json', content_language=None, accept='application/json', accept_language=None, raw_scores=None, csv_headers=None, consumption_preferences=None)[source]

Generates a personality profile based on input text.

Derives personality insights for up to 20 MB of input content written by an author, though the service requires much less text to produce an accurate profile; for more information, see [Providing sufficient input](https://console.bluemix.net/docs/services/personality-insights/input.html#sufficient). Accepts input in Arabic, English, Japanese, Korean, or Spanish and produces output in one of eleven languages. Provide plain text, HTML, or JSON content, and receive results in JSON or CSV format.

Parameters:
  • content (Content) – A maximum of 20 MB of content to analyze, though the service requires much less text; for more information, see [Providing sufficient input](https://console.bluemix.net/docs/services/personality-insights/input.html#sufficient). A JSON request must conform to the Content model.
  • content_type (str) – The type of the input: application/json, text/html, or text/plain. A character encoding can be specified by including a charset parameter. For example, ‘text/html;charset=utf-8’.
  • content_language (str) – The language of the input text for the request: Arabic, English, Japanese, Korean, or Spanish. Regional variants are treated as their parent language; for example, en-US is interpreted as en. The effect of the content_language header depends on the Content-Type header. When Content-Type is text/plain or text/html, content_language is the only way to specify the language. When Content-Type is application/json, content_language overrides a language specified with the language parameter of a ContentItem object, and content items that specify a different language are ignored; omit this header to base the language on the specification of the content items. You can specify any combination of languages for content_language and Accept-Language.
  • accept – Type of the response: ‘application/json’ (default) or ‘text/csv’
  • accept_language (str) – The desired language of the response. For two-character arguments, regional variants are treated as their parent language; for example, en-US is interpreted as en. You can specify any combination of languages for the input and response content.
  • raw_scores (bool) – If true, a raw score in addition to a normalized percentile is returned for each characteristic; raw scores are not compared with a sample population. If false (the default), only normalized percentiles are returned.
  • csv_headers (bool) – If true, column labels are returned with a CSV response; if false (the default), they are not. Applies only when the Accept header is set to text/csv.
  • consumption_preferences (bool) – If true, information about consumption preferences is returned with the results; if false (the default), the response does not include the information.
Returns:

A dict containing the Profile response.

Return type:

dict

class Behavior(trait_id, name, category, percentage)[source]

Bases: object

Behavior.

Attr str trait_id:
 The unique identifier of the characteristic to which the results pertain. IDs have the form behavior_{value}.
Attr str name:The user-visible name of the characteristic.
Attr str category:
 The category of the characteristic: behavior for temporal data.
Attr float percentage:
 For JSON content that is timestamped, the percentage of timestamped input data that occurred during that day of the week or hour of the day. The range is 0 to 1.
class ConsumptionPreferences(consumption_preference_id, name, score)[source]

Bases: object

ConsumptionPreferences.

Attr str consumption_preference_id:
 The unique identifier of the consumption preference to which the results pertain. IDs have the form consumption_preferences_{preference}.
Attr str name:The user-visible name of the consumption preference.
Attr float score:
 The score for the consumption preference: * 0.0: Unlikely * 0.5: Neutral * 1.0: Likely The scores for some preferences are binary and do not allow a neutral value. The score is an indication of preference based on the results inferred from the input text, not a normalized percentile.
class ConsumptionPreferencesCategory(consumption_preference_category_id, name, consumption_preferences)[source]

Bases: object

ConsumptionPreferencesCategory.

Attr str consumption_preference_category_id:
 The unique identifier of the consumption preferences category to which the results pertain. IDs have the form consumption_preferences_{category}.
Attr str name:The user-visible name of the consumption preferences category.
Attr list[ConsumptionPreferences] consumption_preferences:
 Detailed results inferred from the input text for the individual preferences of the category.
class Content(content_items)[source]

Bases: object

Content.

Attr list[ContentItem] content_items:
 An array of ContentItem objects that provides the text that is to be analyzed.
class ContentItem(content, id=None, created=None, updated=None, contenttype=None, language=None, parentid=None, reply=None, forward=None)[source]

Bases: object

ContentItem.

Attr str content:
 Content that is to be analyzed. The service supports up to 20 MB of content for all items combined.
Attr str id:(optional) Unique identifier for this content item.
Attr int created:
 (optional) Timestamp that identifies when this content was created. Specify a value in milliseconds since the UNIX Epoch (January 1, 1970, at 0:00 UTC). Required only for results that include temporal behavior data.
Attr int updated:
 (optional) Timestamp that identifies when this content was last updated. Specify a value in milliseconds since the UNIX Epoch (January 1, 1970, at 0:00 UTC). Required only for results that include temporal behavior data.
Attr str contenttype:
 (optional) MIME type of the content. The default is plain text. The tags are stripped from HTML content before it is analyzed; plain text is processed as submitted.
Attr str language:
 (optional) Language identifier (two-letter ISO 639-1 identifier) for the language of the content item. The default is en (English). Regional variants are treated as their parent language; for example, en-US is interpreted as en. A language specified with the Content-Type header overrides the value of this parameter; any content items that specify a different language are ignored. Omit the Content-Type header to base the language on the most prevalent specification among the content items; again, content items that specify a different language are ignored. You can specify any combination of languages for the input and response content.
Attr str parentid:
 (optional) Unique ID of the parent content item for this item. Used to identify hierarchical relationships between posts/replies, messages/replies, and so on.
Attr bool reply:
 (optional) Indicates whether this content item is a reply to another content item.
Attr bool forward:
 (optional) Indicates whether this content item is a forwarded/copied version of another content item.
class Profile(processed_language, word_count, personality, values, needs, warnings, word_count_message=None, behavior=None, consumption_preferences=None)[source]

Bases: object

Profile.

Attr str processed_language:
 The language model that was used to process the input.
Attr int word_count:
 The number of words that were found in the input.
Attr str word_count_message:
 (optional) When guidance is appropriate, a string that provides a message that indicates the number of words found and where that value falls in the range of required or suggested number of words.
Attr list[Trait] personality:
 Detailed results for the Big Five personality characteristics (dimensions and facets) inferred from the input text.
Attr list[Trait] values:
 Detailed results for the Needs characteristics inferred from the input text.
Attr list[Trait] needs:
 Detailed results for the Values characteristics inferred from the input text.
Attr list[Behavior] behavior:
 (optional) For JSON content that is timestamped, detailed results about the social behavior disclosed by the input in terms of temporal characteristics. The results include information about the distribution of the content over the days of the week and the hours of the day.
Attr list[ConsumptionPreferencesCategory] consumption_preferences:
 (optional) If the consumption_preferences query parameter is true, detailed results for each category of consumption preferences. Each element of the array provides information inferred from the input text for the individual preferences of that category.
Attr list[Warning] warnings:
 Warning messages associated with the input text submitted with the request. The array is empty if the input generated no warnings.
class Trait(trait_id, name, category, percentile, raw_score=None, significant=None, children=None)[source]

Bases: object

Trait.

Attr str trait_id:
 The unique identifier of the characteristic to which the results pertain. IDs have the form big5_{characteristic} for Big Five personality characteristics, need_{characteristic} for Needs, or value_{characteristic} for Values.
Attr str name:The user-visible name of the characteristic.
Attr str category:
 The category of the characteristic: * personality for Big Five personality characteristics * needs for Needs * values for Values.
Attr float percentile:
 The normalized percentile score for the characteristic. The range is 0 to 1. For example, if the percentage for Openness is 0.60, the author scored in the 60th percentile; the author is more open than 59 percent of the population and less open than 39 percent of the population.
Attr float raw_score:
 (optional) The raw score for the characteristic. The range is 0 to 1. A higher score generally indicates a greater likelihood that the author has that characteristic, but raw scores must be considered in aggregate: The range of values in practice might be much smaller than 0 to 1, so an individual score must be considered in the context of the overall scores and their range. The raw score is computed based on the input and the service model; it is not normalized or compared with a sample population. The raw score enables comparison of the results against a different sampling population and with a custom normalization approach.
Attr bool significant:
 (optional) `2017-10-13`: Indicates whether the characteristic is meaningful for the input language. The field is always true for all characteristics of English, Spanish, and Japanese input. The field is false for the subset of characteristics of Arabic and Korean input for which the service’s models are unable to generate meaningful results. `2016-10-20`: Not returned.
Attr list[Trait] children:
 (optional) For personality (Big Five) dimensions, more detailed results for the facets of each dimension as inferred from the input text.
class Warning(warning_id, message)[source]

Bases: object

Warning.

Attr str warning_id:
 The identifier of the warning message.
Attr str message:
 The message associated with the warning_id: * WORD_COUNT_MESSAGE: “There were {number} words in the input. We need a minimum of 600, preferably 1,200 or more, to compute statistically significant estimates.” * JSON_AS_TEXT: “Request input was processed as text/plain as indicated, however detected a JSON input. Did you mean application/json?” * CONTENT_TRUNCATED: “For maximum accuracy while also optimizing processing time, only the first 250KB of input text (excluding markup) was analyzed. Accuracy levels off at approximately 3,000 words so this did not affect the accuracy of the profile.” * PARTIAL_TEXT_USED, “The text provided to compute the profile was trimmed for performance reasons. This action does not affect the accuracy of the output, as not all of the input text was required.” Applies only when Arabic input text exceeds a threshold at which additional words do not contribute to the accuracy of the profile.