ibm_watson.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://cloud.ibm.com/docs/personality-insights?topic=personality-insights-models#models). * For information about the meaning of the consumption preferences, see [Consumption preferences](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-preferences#preferences). Note: Request logging is disabled for the Personality Insights service. Regardless of whether you set the X-Watson-Learning-Opt-Out request header, the service does not log or retain data from requests and responses.

class PersonalityInsightsV3(version: str, authenticator: ibm_cloud_sdk_core.authenticators.authenticator.Authenticator = None, service_name: str = 'personality_insights')[source]

Bases: ibm_cloud_sdk_core.base_service.BaseService

The Personality Insights V3 service.

DEFAULT_SERVICE_URL = 'https://api.us-south.personality-insights.watson.cloud.ibm.com'
DEFAULT_SERVICE_NAME = 'personality_insights'
profile(content: object, accept: str, *, content_type: str = None, content_language: str = None, accept_language: str = None, raw_scores: bool = None, csv_headers: bool = None, consumption_preferences: bool = None, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[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. The service can analyze text in Arabic, English, Japanese, Korean, or Spanish. It can return its results in a variety of languages. See also: * [Requesting a profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#input) * [Providing sufficient input](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#sufficient) ### Content types

You can provide input content as plain text (text/plain), HTML (text/html),

or JSON (application/json) by specifying the Content-Type parameter. The default is text/plain. * 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: [Specifying request and response formats](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#formats) ### Accept types

You must request a response as JSON (application/json) or comma-separated

values (text/csv) by specifying the Accept parameter. CSV output includes a fixed number of columns. Set the csv_headers parameter to true to request optional column headers for CSV output. See also: * [Understanding a JSON profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-output#output) * [Understanding a CSV profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-outputCSV#outputCSV).

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://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#sufficient). For JSON input, provide an object of type Content.

  • accept (str) – The type of the response. For more information, see Accept types in the method description.

  • content_type (str) – (optional) The type of the input. For more information, see Content types in the method description.

  • content_language (str) – (optional) 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.

  • accept_language (str) – (optional) 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) – (optional) 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.

  • csv_headers (bool) – (optional) Indicates whether column labels are returned with a CSV response. By default, no column labels are returned. Applies only when the response type is CSV (text/csv).

  • consumption_preferences (bool) – (optional) Indicates whether consumption preferences are returned with the results. By default, no consumption preferences are returned.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

class ProfileEnums[source]

Bases: object

class Accept(value)[source]

Bases: enum.Enum

The type of the response. For more information, see Accept types in the method description.

APPLICATION_JSON = 'application/json'
TEXT_CSV = 'text/csv'
class ContentType(value)[source]

Bases: enum.Enum

The type of the input. For more information, see Content types in the method description.

APPLICATION_JSON = 'application/json'
TEXT_HTML = 'text/html'
TEXT_PLAIN = 'text/plain'
class ContentLanguage(value)[source]

Bases: enum.Enum

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.

AR = 'ar'
EN = 'en'
ES = 'es'
JA = 'ja'
KO = 'ko'
class AcceptLanguage(value)[source]

Bases: enum.Enum

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.

AR = 'ar'
DE = 'de'
EN = 'en'
ES = 'es'
FR = 'fr'
IT = 'it'
JA = 'ja'
KO = 'ko'
PT_BR = 'pt-br'
ZH_CN = 'zh-cn'
ZH_TW = 'zh-tw'
class Behavior(trait_id: str, name: str, category: str, percentage: float)[source]

Bases: object

The temporal behavior for the input content.

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.

classmethod from_dict(_dict: Dict)ibm_watson.personality_insights_v3.Behavior[source]

Initialize a Behavior object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class ConsumptionPreferences(consumption_preference_id: str, name: str, score: float)[source]

Bases: object

A consumption preference that the service inferred from the input content.

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.

classmethod from_dict(_dict: Dict)ibm_watson.personality_insights_v3.ConsumptionPreferences[source]

Initialize a ConsumptionPreferences object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class ConsumptionPreferencesCategory(consumption_preference_category_id: str, name: str, consumption_preferences: List[ConsumptionPreferences])[source]

Bases: object

The consumption preferences that the service inferred from the input content.

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.

classmethod from_dict(_dict: Dict)ibm_watson.personality_insights_v3.ConsumptionPreferencesCategory[source]

Initialize a ConsumptionPreferencesCategory object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class Content(content_items: List[ContentItem])[source]

Bases: object

The full input content that the service is to analyze.

Attr List[ContentItem] content_items

An array of ContentItem objects that provides the text that is to be analyzed.

classmethod from_dict(_dict: Dict)ibm_watson.personality_insights_v3.Content[source]

Initialize a Content object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class ContentItem(content: str, *, id: str = None, created: int = None, updated: int = None, contenttype: str = None, language: str = None, parentid: str = None, reply: bool = None, forward: bool = None)[source]

Bases: object

An input content item that the service is to analyze.

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.

classmethod from_dict(_dict: Dict)ibm_watson.personality_insights_v3.ContentItem[source]

Initialize a ContentItem object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class ContenttypeEnum(value)[source]

Bases: enum.Enum

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.

TEXT_PLAIN = 'text/plain'
TEXT_HTML = 'text/html'
class LanguageEnum(value)[source]

Bases: enum.Enum

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.

AR = 'ar'
EN = 'en'
ES = 'es'
JA = 'ja'
KO = 'ko'
class Profile(processed_language: str, word_count: int, personality: List[Trait], needs: List[Trait], values: List[Trait], warnings: List[Warning], *, word_count_message: str = None, behavior: List[Behavior] = None, consumption_preferences: List[ConsumptionPreferencesCategory] = None)[source]

Bases: object

The personality profile that the service generated for the input content.

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

An array of warning messages that are associated with the input text for the request. The array is empty if the input generated no warnings.

classmethod from_dict(_dict: Dict)ibm_watson.personality_insights_v3.Profile[source]

Initialize a Profile object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class ProcessedLanguageEnum(value)[source]

Bases: enum.Enum

The language model that was used to process the input.

AR = 'ar'
EN = 'en'
ES = 'es'
JA = 'ja'
KO = 'ko'
class Trait(trait_id: str, name: str, category: str, percentile: float, *, raw_score: float = None, significant: bool = None, children: List[Trait] = None)[source]

Bases: object

The characteristics that the service inferred from the input content.

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.

classmethod from_dict(_dict: Dict)ibm_watson.personality_insights_v3.Trait[source]

Initialize a Trait object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class CategoryEnum(value)[source]

Bases: enum.Enum

The category of the characteristic: personality for Big Five personality characteristics, needs for Needs, and values for Values.

PERSONALITY = 'personality'
NEEDS = 'needs'
VALUES = 'values'
class Warning(warning_id: str, message: str)[source]

Bases: object

A warning message that is associated with the input content.

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.

classmethod from_dict(_dict: Dict)ibm_watson.personality_insights_v3.Warning[source]

Initialize a Warning object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class WarningIdEnum(value)[source]

Bases: enum.Enum

The identifier of the warning message.

WORD_COUNT_MESSAGE = 'WORD_COUNT_MESSAGE'
JSON_AS_TEXT = 'JSON_AS_TEXT'
CONTENT_TRUNCATED = 'CONTENT_TRUNCATED'
PARTIAL_TEXT_USED = 'PARTIAL_TEXT_USED'