Contract element extraction - General realm

更新时间:
复制 MD 格式

The Contract Element Extraction service for the general realm extracts elements from contracts. This service supports 26 general element fields. For a detailed list of supported fields, see the appendix.

Note

This service is provided by the Natural Language Processing (NLP) Self-Learning Platform. You can call the API directly to use this service.

Activate the service and purchase a resource plan

Before you use the service, ensure that it is activated. You can purchase a resource plan after the service is activated.

Service invocation and debugging

For more information about how to call the model, see Model invocation.

For software development kit (SDK) examples, see SDK examples.

Debug

You can run this API operation directly in the OpenAPI Developer Portal to avoid calculating signatures. After the operation is successfully run, the OpenAPI Developer Portal automatically generates SDK code examples.

Configure access credentials using environment variables

  1. Notes:

    1. Because an AccessKey for an Alibaba Cloud account has full API access permissions, it poses a high security threat. We recommend that you create and use a Resource Access Management (RAM) user for API calls and routine O&M. To create a RAM user, log on to the RAM console.

    2. Do not save your AccessKey ID and AccessKey secret in your code because this can lead to key leakage. Instead, configure environment variables to store and use your credentials.

  2. Configuring Linux and macOS

    export NLP_AK_ENV=<access_key_id>
    export NLP_SK_ENV=<access_key_secret>

    Replace <access_key_id> with your AccessKey ID and <access_key_secret> with your AccessKey secret. For more information about how to obtain an AccessKey ID and an AccessKey secret, see Step 2: Obtain an AccessKey for your account.

  3. Configuration method for Windows

    1. Create an environment variable file. In the file, add the NLP_AK_ENV and NLP_SK_ENV environment variables. Then, write your AccessKey ID and AccessKey secret to the file.

    2. Restart Windows.

Java code example

/**
 * An AccessKey for an Alibaba Cloud account has full API access permissions, which poses a high security threat.
 * We strongly recommend that you create and use a RAM user for API calls or routine O&M.
 * Log on to the RAM console to create a RAM user.
 * This example shows how to save the AccessKey ID and AccessKey secret in environment variables.
 * You can also save them in a configuration file as needed.
 * We strongly recommend that you do not save the AccessKey ID and AccessKey secret in your code. This can lead to key leakage.
 */
String accessKeyId = System.getenv("NLP_AK_ENV");
String accessKeySecret = System.getenv("NLP_SK_ENV");
DefaultProfile defaultProfile = DefaultProfile.getProfile("cn-hangzhou",accessKeyId,accessKeySecret);
IAcsClient client = new DefaultAcsClient(defaultProfile);
String content = "Party A: Shenzhen aaa Electron Co., Ltd. Party B: Shenzhen BBB Labor Dispatch Co., Ltd.";
RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
request.setServiceName("ContractNERPretrain");
request.setPredictContent(content);
RunPreTrainServiceResponse response = client.getAcsResponse(request);
System.out.println(response.getPredictResult());

Python code example

# Install dependencies
pip install aliyun-python-sdk-core
pip install aliyun-python-sdk-nlp-automl
# -*- coding: utf8 -*-
import json
import os

from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdknlp_automl.request.v20191111 import RunPreTrainServiceRequest

# An AccessKey for an Alibaba Cloud account has full API access permissions, which poses a high security threat.
# We strongly recommend that you create and use a RAM user for API calls or routine O&M.
# Log on to the RAM console to create a RAM user.
# This example shows how to save the AccessKey ID and AccessKey secret in environment variables.
# You can also save them in a configuration file as needed.
# We strongly recommend that you do not save the AccessKey ID and AccessKey secret in your code. This can lead to key leakage.
access_key_id = os.environ['NLP_AK_ENV']
access_key_secret = os.environ['NLP_SK_ENV']

# Initialize AcsClient instance
client = AcsClient(
  access_key_id,
  access_key_secret,
  "cn-hangzhou"
);

content = 'Party A: Shenzhen aaa Electron Co., Ltd. Party B: Shenzhen BBB Labor Dispatch Co., Ltd.'

# Initialize a request and set parameters
request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
request.set_ServiceName('ContractNERPretrain')
request.set_PredictContent(content)

# Print response
response = client.do_action_with_exception(request)
resp_obj = json.loads(response)
predict_result = json.loads(resp_obj['PredictResult'])
print(predict_result)

Sample input:

Temporary Worker Dispatch Agreement
Party A: Shenzhen aaa Electron Co., Ltd. Party B: Shenzhen BBB Labor Dispatch Co., Ltd.
Address: A Industrial Park, X Avenue, Shenzhen Address: Room 1010, Building B, No. 1 S East Road, Z Office, Y District, Shenzhen
Legal Representative: Han Liu
Legal Representative: Wang Wu
Authorized Representative: Li Si
Authorized Representative: Zhang San
Phone: 89601111
Phone: 1390000****
Party A faces tight production schedules and a staff shortage. To meet labor needs and ensure normal operations, Party A and Party B sign this agreement. This agreement concerns Party B sending temporary workers to Party A. It is based on the principles of equality and mutual agreement, and follows the Contract Law and Labor Contract Law of the People's Republic of China and other relevant regulations. Both parties agree to follow the terms of this agreement.
Party A accepts and agrees:
Party B accepts and agrees:
Party A Representative Signature:
Party B Representative Signature:

Sample response:

[
  {
    "id": 0,
    "sent_offsets": 0,
    "sentence": "Temporary Worker Dispatch Agreement\nParty A: Shenzhen aaa Electron Co., Ltd. Party B: Shenzhen BBB Labor Dispatch Co., Ltd.\nAddress: A Industrial Park, X Avenue, Shenzhen Address: Room 1010, Building B, No. 1 S East Road, Z Office, Y District, Shenzhen\nLegal Representative: Han Liu\nLegal Representative: Wang Wu\nAuthorized Representative: Li Si\nAuthorized Representative: Zhang San\nPhone: 89601111\nPhone: 1390000****\nParty A faces tight production schedules and a staff shortage. To meet labor needs and ensure normal operations, Party A and Party B sign this agreement. This agreement concerns Party B sending temporary workers to Party A. It is based on the principles of equality and mutual agreement, and follows the Contract Law and Labor Contract Law of the People's Republic of China and other relevant regulations. Both parties agree to follow the terms of this agreement.\nParty A accepts and agrees:\nParty B accepts and agrees:\nParty A Representative Signature:\nParty B Representative Signature:",
    "tags": [
      {
        "class": "contract_name",
        "conf": 1.0,
        "start": 0,
        "end": 7,
        "span": "Temporary Worker Dispatch Agreement",
        "source": "model"
      },
      {
        "class": "party_a_name",
        "conf": 1.0,
        "start": 11,
        "end": 24,
        "span": "Shenzhen aaa Electron Co., Ltd. ",
        "source": "model"
      },
      {
        "class": "party_b_name",
        "conf": 1.0,
        "start": 27,
        "end": 41,
        "span": "Shenzhen BBB Labor Dispatch Co., Ltd.",
        "source": "model"
      },
      {
        "class": "party_a_address",
        "conf": 1.0,
        "start": 45,
        "end": 56,
        "span": "A Industrial Park, X Avenue, Shenzhen ",
        "source": "model"
      },
      {
        "class": "party_b_address",
        "conf": 1.0,
        "start": 59,
        "end": 80,
        "span": "Room 1010, Building B, No. 1 S East Road, Z Office, Y District, Shenzhen",
        "source": "model"
      }
    ]
  }
]

Parameter description

Parameter

Description

sentence

The original input text. Use "\n" as a separator.

sent_offsets

Format alignment. This service sets the value to 0.

id

Format alignment. This service sets the value to 0.

tags

The detected elements.

start

The start position of the element.

end

The end position of the element.

source

model

class

The element category. A total of 26 categories are supported.

span

The character sequence that corresponds to the extracted element.

Appendix: Contract element extraction fields and descriptions

No.

Entity name

Description

1

Contract name

2

Contract number

3

Contract term

4

Number of contract copies

5

Contract amount

6

Contract amount in numerals

7

Contract amount in words

8

Tax rate

9

Start time

10

End time

11

Signing time

12

Effective time

13

Party A name

14

Party A seal/signature name

15

Party A bank account number

16

Party A's bank account

17

Party A bank name

18

Party A address

19

Party B name

20

Party B seal/signature name

21

Party B bank account number

22

Party B's bank account

23

Party B bank name

24

Party B address

25

Court of litigation

26

Arbitration institution