PersonalityInsights

public class PersonalityInsights

IBM Watson™ Personality Insights is discontinued. Existing instances are supported until 1 December 2021, but as of 1 December 2020, you cannot create new instances. Any instance that exists on 1 December 2021 will be deleted.

No direct replacement exists for Personality Insights. However, you can consider using IBM Watson™ Natural Language Understanding on IBM Cloud® as part of a replacement analytic workflow for your Personality Insights use cases. You can use Natural Language Understanding to extract data and insights from text, such as keywords, categories, sentiment, emotion, and syntax. For more information about the personality models in Personality Insights, see The science behind the service. {: deprecated} 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.
  • For information about the meaning of the consumption preferences, see Consumption 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.
  • The base URL to use when contacting the service.

    Declaration

    Swift

    public var serviceURL: String?
  • Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is 2017-10-13.

    Declaration

    Swift

    public var version: String
  • Service identifiers

    Declaration

    Swift

    public static let defaultServiceName: String
  • The default HTTP headers for all requests to the service.

    Declaration

    Swift

    public var defaultHeaders: [String : String]
  • Undocumented

    Declaration

    Swift

    public let authenticator: Authenticator
  • Create a PersonalityInsights object.

    If an authenticator is not supplied, the initializer will retrieve credentials from the environment or a local credentials file and construct an appropriate authenticator using these credentials. The credentials file can be downloaded from your service instance on IBM Cloud as ibm-credentials.env. Make sure to add the credentials file to your project so that it can be loaded at runtime.

    If an authenticator is not supplied and credentials are not available in the environment or a local credentials file, initialization will fail by throwing an exception. In that case, try another initializer that directly passes in the credentials.

    • serviceName: String = defaultServiceName
  • Create a PersonalityInsights object.

    Declaration

    Swift

    public init(version: String, authenticator: Authenticator)

    Parameters

    version

    Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is 2017-10-13.

    authenticator

    The Authenticator object used to authenticate requests to the service

  • Allow network requests to a server without verification of the server certificate. IMPORTANT: This should ONLY be used if truly intended, as it is unsafe otherwise.

    Declaration

    Swift

    public func disableSSLVerification()
  • 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
    • Providing sufficient input ### 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 ### 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
    • Understanding a CSV profile.

    Declaration

    Swift

    public func profile(
        profileContent: ProfileContent,
        contentLanguage: String? = nil,
        acceptLanguage: String? = nil,
        rawScores: Bool? = nil,
        csvHeaders: Bool? = nil,
        consumptionPreferences: Bool? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Profile>?, WatsonError?) -> Void)

    Parameters

    profileContent

    A maximum of 20 MB of content to analyze, though the service requires much less text; for more information, see Providing sufficient input. For JSON input, provide an object of type Content.

    contentLanguage

    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.

    acceptLanguage

    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.

    rawScores

    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.

    csvHeaders

    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).

    consumptionPreferences

    Indicates whether consumption preferences are returned with the results. By default, no consumption preferences are returned.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Get profile as csv.

    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
    • Providing sufficient input ### 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 ### 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
    • Understanding a CSV profile.

    Declaration

    Swift

    public func profileAsCSV(
        profileContent: ProfileContent,
        contentLanguage: String? = nil,
        acceptLanguage: String? = nil,
        rawScores: Bool? = nil,
        csvHeaders: Bool? = nil,
        consumptionPreferences: Bool? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Data>?, WatsonError?) -> Void)

    Parameters

    profileContent

    A maximum of 20 MB of content to analyze, though the service requires much less text; for more information, see Providing sufficient input. For JSON input, provide an object of type Content.

    contentLanguage

    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.

    acceptLanguage

    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.

    rawScores

    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.

    csvHeaders

    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).

    consumptionPreferences

    Indicates whether consumption preferences are returned with the results. By default, no consumption preferences are returned.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error