watson_developer_cloud.personality_insights_v3 module

The IBM Watson™ Personality Insights service 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 infer consumption preferences based on the results of its analysis and, for JSON content that is timestamped, can report temporal behavior. * For information about the meaning of the models that the service uses to describe personality characteristics, see [Personality models](https://console.bluemix.net/docs/services/personality-insights/models.html). * For information about the meaning of the consumption preferences, see [Consumption preferences](https://console.bluemix.net/docs/services/personality-insights/preferences.html). Note: Request logging is disabled for the Personality Insights service. The service neither logs nor retains data from requests and responses, regardless of whether the X-Watson-Learning-Opt-Out request header is set.

class PersonalityInsightsV3(version, url='https://gateway.watsonplatform.net/personality-insights/api', username=None, password=None, iam_apikey=None, iam_access_token=None, iam_url=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, accept=None, content_language=None, accept_language=None, raw_scores=None, csv_headers=None, consumption_preferences=None, **kwargs)[source]

Get profile.

Generates a personality profile for the author of the input text. The service accepts a maximum of 20 MB of input content, but it 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). The service analyzes text in Arabic, English, Japanese, Korean, or Spanish and returns its results in a variety of languages. You can provide plain text, HTML, or JSON input by specifying the Content-Type parameter; the default is text/plain. Request a JSON or comma-separated values (CSV) response by specifying the Accept parameter; CSV output includes a fixed number of columns and optional headers. Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8; per the HTTP specification, the default encoding for plain text and HTML is ISO-8859-1 (effectively, the ASCII character set). When specifying a content type of plain text or HTML, include the charset parameter to indicate the character encoding of the input text; for example: Content-Type: text/plain;charset=utf-8. See also: * [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) * [Understanding a CSV profile](https://console.bluemix.net/docs/services/personality-insights/output-csv.html).

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). For JSON input, provide an object of type Content. :param str content_type: The type of the input. A character encoding can be specified by including a charset parameter. For example, ‘text/html;charset=utf-8’. :param str accept: The type of the response: application/json or text/csv. A character encoding can be specified by including a charset parameter. For example, ‘text/csv;charset=utf-8’. :param str content_language: 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 parameter depends on the Content-Type parameter. 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 parameter to base the language on the specification of the content items. You can specify any combination of languages for Content-Language and Accept-Language. :param str accept_language: 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. :param bool raw_scores: Indicates whether a raw score in addition to a normalized percentile is returned for each characteristic; raw scores are not compared with a sample population. By default, only normalized percentiles are returned. :param bool csv_headers: Indicates whether column labels are returned with a CSV response. By default, no column labels are returned. Applies only when the Accept parameter is set to text/csv. :param bool consumption_preferences: Indicates whether consumption preferences are returned with the results. By default, no consumption preferences are returned. :param dict headers: A dict containing the request headers :return: A DetailedResponse containing the result, headers and HTTP status code. :rtype: DetailedResponse

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

Bases: object

Behavior.

Attr str trait_id:
 The unique, non-localized identifier of the characteristic to

which the results pertain. IDs have the form behavior_{value}. :attr str name: The user-visible, localized 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, non-localized identifier of the

consumption preference to which the results pertain. IDs have the form consumption_preferences_{preference}. :attr str name: The user-visible, localized 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, non-localized 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:
 The content that is to be analyzed. The service supports up to 20

MB of content for all ContentItem objects combined. :attr str id: (optional) A unique identifier for this content item. :attr int created: (optional) A 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) A 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) The 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) The 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 parameter overrides the value of this parameter; any content items that specify a different language are ignored. Omit the Content-Type parameter 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) The 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, needs, values, 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 from the input that were used to produce the

profile. :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: A recursive array of Trait objects that provides detailed results for the Big Five personality characteristics (dimensions and facets) inferred from the input text. :attr list[Trait] needs: Detailed results for the Needs characteristics inferred from the input text. :attr list[Trait] values: 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 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, non-localized identifier of the characteristic to

which the results pertain. IDs have the form * big5_{characteristic} for Big Five personality dimensions * facet_{characteristic} for Big Five personality facets * need_{characteristic} for Needs

*value_{characteristic} for Values.
Attr str name:The user-visible, localized name of the characteristic.
Attr str category:
 The category of the characteristic: personality for Big Five

personality characteristics, needs for Needs, and 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-19`: 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.