CompareComply

public class CompareComply

IBM Watson™ Compare and Comply is discontinued. Existing instances are supported until 30 November 2021, but as of 1 December 2020, you can’t create instances. Any instance that exists on 30 November 2021 will be deleted. Consider migrating to Watson Discovery Premium on IBM Cloud for your Compare and Comply use cases. To start the migration process, visit https://ibm.biz/contact-wdc-premium. {: deprecated} Compare and Comply analyzes governing documents to provide details about critical aspects of the documents.

  • 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 2018-10-15.

    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 CompareComply 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 CompareComply 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 2018-10-15.

    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()
  • Convert document to HTML.

    Converts a document to HTML.

    Declaration

    Swift

    public func convertToHTML(
        file: Data,
        fileContentType: String? = nil,
        model: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<HTMLReturn>?, WatsonError?) -> Void)

    Parameters

    file

    The document to convert.

    fileContentType

    The content type of file.

    model

    The analysis model to be used by the service. For the Element classification and Compare two documents methods, the default is contracts. For the Extract tables method, the default is tables. These defaults apply to the standalone methods as well as to the methods’ use in batch-processing requests.

    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

  • Classify the elements of a document.

    Analyzes the structural and semantic elements of a document.

    Declaration

    Swift

    public func classifyElements(
        file: Data,
        fileContentType: String? = nil,
        model: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<ClassifyReturn>?, WatsonError?) -> Void)

    Parameters

    file

    The document to classify.

    fileContentType

    The content type of file.

    model

    The analysis model to be used by the service. For the Element classification and Compare two documents methods, the default is contracts. For the Extract tables method, the default is tables. These defaults apply to the standalone methods as well as to the methods’ use in batch-processing requests.

    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

  • Extract a document’s tables.

    Analyzes the tables in a document.

    Declaration

    Swift

    public func extractTables(
        file: Data,
        fileContentType: String? = nil,
        model: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TableReturn>?, WatsonError?) -> Void)

    Parameters

    file

    The document on which to run table extraction.

    fileContentType

    The content type of file.

    model

    The analysis model to be used by the service. For the Element classification and Compare two documents methods, the default is contracts. For the Extract tables method, the default is tables. These defaults apply to the standalone methods as well as to the methods’ use in batch-processing requests.

    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

  • Compare two documents.

    Compares two input documents. Documents must be in the same format.

    Declaration

    Swift

    public func compareDocuments(
        file1: Data,
        file2: Data,
        file1ContentType: String? = nil,
        file2ContentType: String? = nil,
        file1Label: String? = nil,
        file2Label: String? = nil,
        model: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<CompareReturn>?, WatsonError?) -> Void)

    Parameters

    file1

    The first document to compare.

    file2

    The second document to compare.

    file1ContentType

    The content type of file1.

    file2ContentType

    The content type of file2.

    file1Label

    A text label for the first document.

    file2Label

    A text label for the second document.

    model

    The analysis model to be used by the service. For the Element classification and Compare two documents methods, the default is contracts. For the Extract tables method, the default is tables. These defaults apply to the standalone methods as well as to the methods’ use in batch-processing requests.

    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

  • Add feedback.

    Adds feedback in the form of labels from a subject-matter expert (SME) to a governing document. Important: Feedback is not immediately incorporated into the training model, nor is it guaranteed to be incorporated at a later date. Instead, submitted feedback is used to suggest future updates to the training model.

    Declaration

    Swift

    public func addFeedback(
        feedbackData: FeedbackDataInput,
        userID: String? = nil,
        comment: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<FeedbackReturn>?, WatsonError?) -> Void)

    Parameters

    feedbackData

    Feedback data for submission.

    userID

    An optional string identifying the user.

    comment

    An optional comment on or description of the feedback.

    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

  • List the feedback in a document.

    Lists the feedback in a document.

    Declaration

    Swift

    public func listFeedback(
        feedbackType: String? = nil,
        documentTitle: String? = nil,
        modelID: String? = nil,
        modelVersion: String? = nil,
        categoryRemoved: String? = nil,
        categoryAdded: String? = nil,
        categoryNotChanged: String? = nil,
        typeRemoved: String? = nil,
        typeAdded: String? = nil,
        typeNotChanged: String? = nil,
        pageLimit: Int? = nil,
        cursor: String? = nil,
        sort: String? = nil,
        includeTotal: Bool? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<FeedbackList>?, WatsonError?) -> Void)

    Parameters

    feedbackType

    An optional string that filters the output to include only feedback with the specified feedback type. The only permitted value is element_classification.

    documentTitle

    An optional string that filters the output to include only feedback from the document with the specified document_title.

    modelID

    An optional string that filters the output to include only feedback with the specified model_id. The only permitted value is contracts.

    modelVersion

    An optional string that filters the output to include only feedback with the specified model_version.

    categoryRemoved

    An optional string in the form of a comma-separated list of categories. If it is specified, the service filters the output to include only feedback that has at least one category from the list removed.

    categoryAdded

    An optional string in the form of a comma-separated list of categories. If this is specified, the service filters the output to include only feedback that has at least one category from the list added.

    categoryNotChanged

    An optional string in the form of a comma-separated list of categories. If this is specified, the service filters the output to include only feedback that has at least one category from the list unchanged.

    typeRemoved

    An optional string of comma-separated nature:party pairs. If this is specified, the service filters the output to include only feedback that has at least one nature:party pair from the list removed.

    typeAdded

    An optional string of comma-separated nature:party pairs. If this is specified, the service filters the output to include only feedback that has at least one nature:party pair from the list removed.

    typeNotChanged

    An optional string of comma-separated nature:party pairs. If this is specified, the service filters the output to include only feedback that has at least one nature:party pair from the list unchanged.

    pageLimit

    An optional integer specifying the number of documents that you want the service to return.

    cursor

    An optional string that returns the set of documents after the previous set. Use this parameter with the page_limit parameter.

    sort

    An optional comma-separated list of fields in the document to sort on. You can optionally specify the sort direction by prefixing the value of the field with - for descending order or + for ascending order (the default). Currently permitted sorting fields are created, user_id, and document_title.

    includeTotal

    An optional boolean value. If specified as true, the pagination object in the output includes a value called total that gives the total count of feedback created.

    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 a specified feedback entry.

    Gets a feedback entry with a specified feedback_id.

    Declaration

    Swift

    public func getFeedback(
        feedbackID: String,
        model: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<GetFeedback>?, WatsonError?) -> Void)

    Parameters

    feedbackID

    A string that specifies the feedback entry to be included in the output.

    model

    The analysis model to be used by the service. For the Element classification and Compare two documents methods, the default is contracts. For the Extract tables method, the default is tables. These defaults apply to the standalone methods as well as to the methods’ use in batch-processing requests.

    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

  • Delete a specified feedback entry.

    Deletes a feedback entry with a specified feedback_id.

    Declaration

    Swift

    public func deleteFeedback(
        feedbackID: String,
        model: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<FeedbackDeleted>?, WatsonError?) -> Void)

    Parameters

    feedbackID

    A string that specifies the feedback entry to be deleted from the document.

    model

    The analysis model to be used by the service. For the Element classification and Compare two documents methods, the default is contracts. For the Extract tables method, the default is tables. These defaults apply to the standalone methods as well as to the methods’ use in batch-processing requests.

    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

  • Submit a batch-processing request.

    Run Compare and Comply methods over a collection of input documents. Important: Batch processing requires the use of the IBM Cloud Object Storage service. The use of IBM Cloud Object Storage with Compare and Comply is discussed at Using batch processing.

    Declaration

    Swift

    public func createBatch(
        function: String,
        inputCredentialsFile: Data,
        inputBucketLocation: String,
        inputBucketName: String,
        outputCredentialsFile: Data,
        outputBucketLocation: String,
        outputBucketName: String,
        model: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<BatchStatus>?, WatsonError?) -> Void)

    Parameters

    function

    The Compare and Comply method to run across the submitted input documents.

    inputCredentialsFile

    A JSON file containing the input Cloud Object Storage credentials. At a minimum, the credentials must enable READ permissions on the bucket defined by the input_bucket_name parameter.

    inputBucketLocation

    The geographical location of the Cloud Object Storage input bucket as listed on the Endpoint tab of your Cloud Object Storage instance; for example, us-geo, eu-geo, or ap-geo.

    inputBucketName

    The name of the Cloud Object Storage input bucket.

    outputCredentialsFile

    A JSON file that lists the Cloud Object Storage output credentials. At a minimum, the credentials must enable READ and WRITE permissions on the bucket defined by the output_bucket_name parameter.

    outputBucketLocation

    The geographical location of the Cloud Object Storage output bucket as listed on the Endpoint tab of your Cloud Object Storage instance; for example, us-geo, eu-geo, or ap-geo.

    outputBucketName

    The name of the Cloud Object Storage output bucket.

    model

    The analysis model to be used by the service. For the Element classification and Compare two documents methods, the default is contracts. For the Extract tables method, the default is tables. These defaults apply to the standalone methods as well as to the methods’ use in batch-processing requests.

    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

  • List submitted batch-processing jobs.

    Lists batch-processing jobs submitted by users.

    Declaration

    Swift

    public func listBatches(
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Batches>?, WatsonError?) -> Void)

    Parameters

    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 information about a specific batch-processing job.

    Gets information about a batch-processing job with a specified ID.

    Declaration

    Swift

    public func getBatch(
        batchID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<BatchStatus>?, WatsonError?) -> Void)

    Parameters

    batchID

    The ID of the batch-processing job whose information you want to retrieve.

    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

  • Update a pending or active batch-processing job.

    Updates a pending or active batch-processing job. You can rescan the input bucket to check for new documents or cancel a job.

    Declaration

    Swift

    public func updateBatch(
        batchID: String,
        action: String,
        model: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<BatchStatus>?, WatsonError?) -> Void)

    Parameters

    batchID

    The ID of the batch-processing job you want to update.

    action

    The action you want to perform on the specified batch-processing job.

    model

    The analysis model to be used by the service. For the Element classification and Compare two documents methods, the default is contracts. For the Extract tables method, the default is tables. These defaults apply to the standalone methods as well as to the methods’ use in batch-processing requests.

    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