Bidding announcement type classification service

更新时间:
复制 MD 格式

This document describes how to call the bidding announcement type classification service.

This service is used as a preprocessing step for the Bidding Parsing Service (Premium Edition) and the Bid-winning Parsing Service (Premium Edition).

Note

This service is provided by the NLP Self-learning Platform. You can use the service by calling the API directly.

Service activation and resource plan purchase

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

Service invocation and debugging

Model invocation documentation: Model invocation

SDK example documentation: SDK examples

Debugging

You can run this API operation in the OpenAPI Developer Portal to avoid calculating signatures. After a successful call, the portal automatically generates sample SDK code.

Configure access credentials using environment variables

  1. Notes:

    1. An AccessKey for an Alibaba Cloud account has permissions for all APIs, which poses a high security risk. We recommend that you create and use a Resource Access Management (RAM) user for API access or daily 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. This practice poses a high risk of key leakage. Instead, use environment variables to store and access your credentials.

  2. Configuration for 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 an account.

  3. Windows configuration

    1. Create a file for the environment variables. Add the NLP_AK_ENV and NLP_SK_ENV environment variables, and then write your AccessKey ID and AccessKey secret to the corresponding variables.

    2. Restart Windows.

To call the bidding announcement type classification service, set ServiceName to classify-type-bid.

Java code example

/**
 * An AccessKey for an Alibaba Cloud account has permissions for all APIs, which poses a high security threat. Create and use a RAM user for API access or daily O&M. Log on to the RAM console to create a RAM user.
 * This example shows how to store the AccessKey ID and AccessKey secret in environment variables. You can also store them in a configuration file as needed.
 * Do not hardcode your AccessKey ID and AccessKey secret in your code. This practice poses a security threat from leaked keys.
 */
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 = "Announcement of Successful Bidder Candidates for the Survey and Design of the 2021 High-Standard Farmland Construction Project (Section 1) in Yangming District, Mudanjiang City";
RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
request.setServiceName("classify-type-bid");
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 permissions for all APIs, which poses a high security threat. Create and use a RAM user for API access or daily O&M. Log on to the RAM console to create a RAM user.
# This example shows how to store the AccessKey ID and AccessKey secret in environment variables. You can also store them in a configuration file as needed.
# Do not hardcode your AccessKey ID and AccessKey secret in your code. This practice poses a security threat from leaked keys.
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 = 'Announcement of Successful Bidder Candidates for the Survey and Design of the 2021 High-Standard Farmland Construction Project (Section 1) in Yangming District, Mudanjiang City'

# Initialize a request and set parameters
request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
request.set_ServiceName('classify-type-bid')
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)
Note

PredictResult is a JSON string. You must deserialize it before you can parse it.

Sample response:

{
  "type": [
    [
      {
        "score": 0.922555685043335,
        "key": "Bid-winning"
      },
      {
        "score": 0.08074402064085007,
        "key": "Bidding"
      }
    ]
  ]
}

Field descriptions

Field

Description

type

key

The type of announcement. Valid values are "Bidding" and "Bid-winning".

score

The probability score for the announcement type. The value is between 0 and 1.