Product review parsing service - Automotive

更新时间:
复制 MD 格式

This service parses product reviews in the automotive field.

This topic describes how to use the product review parsing service for the automotive field. If the currently supported domains and industries do not meet your needs, you can join the NLP Self-Learning Platform Q&A Group 2 on DingTalk (Group ID: 44619071) for further assistance.

Note

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

Activate the service and purchase a resource plan

Before you start, confirm that the service is activated. After the service is activated, you can purchase a resource plan.

Service invocation and debugging

For 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 OpenAPI Explorer. This eliminates the need to calculate signatures. After a successful call, OpenAPI Explorer automatically generates sample SDK code.

Configure access credentials (AKSK) using environment variables

  1. Notes:

    1. An AccessKey for an Alibaba Cloud account has full access permissions to all APIs. This poses a high security threat. We strongly recommend that you create and use a Resource Access Management (RAM) user to make API calls or perform routine operations and maintenance (O&M). To create a RAM user, log on to the RAM console.

    2. To prevent security threats from key leaks, do not hard-code your AccessKey ID and AccessKey secret in your code. Instead, configure them as environment variables.

  2. Configuration on 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.

  3. Configuration on Windows

    1. Create an environment variable file, add the NLP_AK_ENV and NLP_SK_ENV environment variables, and then enter your AccessKey ID and AccessKey secret.

    2. Restart Windows.

Note

To call the product review parsing service for the automotive domain, set the ServiceName parameter to aoe-automl-app-car.

Java code sample

/**
 * An AccessKey of an Alibaba Cloud account has full access permissions to all APIs. This poses a high security threat. We strongly recommend that you create and use a RAM user to make API calls or perform routine O&M. To create a RAM user, log on to the RAM console.
 * 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.
 * To prevent security threats from key leaks, do not hard-code your AccessKey ID and AccessKey secret in your code.
 */
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);

Map<String, Object> input = new HashMap();
input.put("content","A vague smell occurs on frequent uphill starts. I am not sure if the clutch plate is faulty. The reverse gear only engages after a full stop.");
input.put("domain","car");
input.put("entity",true);
Map<String, Object> map = new HashMap<>();
map.put("input", input);

RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
request.setServiceName("aoe-automl-app-car");
request.setPredictContent(JSON.toJSONString(map));
RunPreTrainServiceResponse response = client.getAcsResponse(request);
System.out.println(response.getPredictResult());

Python code sample

# 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 of an Alibaba Cloud account has full access permissions to all APIs. This poses a high security threat. We strongly recommend that you create and use a RAM user to make API calls or perform routine O&M. To create a RAM user, log on to the RAM console.
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.
To prevent security threats from key leaks, do not hard-code your AccessKey ID and AccessKey secret in your code.
"""
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 = 'A vague smell occurs on frequent uphill starts. I am not sure if the clutch plate is faulty. The reverse gear only engages after a full stop.'
domain = 'car'
input_params = {
    "input": {
        "content": content,
        "domain": domain,
        "entity": True
    }
}

# Initialize a request and set parameters
request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
request.set_ServiceName('aoe-automl-app-car')
request.set_PredictContent(json.dumps(input_params))

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

Sample PredictContent

The PredictContent parameter is a JSON string, as shown in the following example.

{
  "input": {
    "content": "A vague smell occurs on frequent uphill starts. I am not sure if the clutch plate is faulty. The reverse gear only engages after a full stop.",
    "domain": "car",
    "entity": true
  }
}

Request parameters

Parameter

Description

content

The text to predict. The maximum length is 500 characters.

domain

The supported product category. For more information, see the supported properties table in the next section.

entity

If the value is true, the result includes the extracted aspect-sentiment terms. Otherwise, it does not.

Table of supported properties

Overall

Freebie

Packaging

Authenticity

Logistics

Brand

Color

Workmanship

Feel

Function

Weight

Sound

Quality

Fit

Navigation

Accessories

Fuel consumption

Interior

Lights

Other

Durability

Practicality

Security

Stability

Convenience

Sealing

Handling

Firmness

Hardness/Softness

Color fastness

Comfort

Precision

Performance

Sound insulation

Display effect

Sound effect

Shock absorption

System performance

Transmission performance

Cornering performance

Fabric/Material

Battery/Battery life

Size

Odor/Smell

Capacity/Space

Gear shifting

Windows/Mirrors

Power/Acceleration

Air conditioner/Refrigerator

Jerkiness

Value for money

Multimedia

Dashboard

Exterior design

Seller service

Driving visibility

Description match

Braking performance

Safety features

Smart assistance

Radar function

4S store service

Maintenance

Vehicle configuration

Anti-theft system

Connected car features

Intelligent Imaging

Control buttons

Sample PredictResult

The PredictResult is a JSON string that you must deserialize for parsing. The following example shows the specific structure.

{
  "code": 1000,
  "data": {
    "cost": "39.912ms",
    "textProb": 0.9975,
    "aspectItem": [
      {
        "clause": "A vague smell occurs on frequent uphill starts",
        "clauseIndex": "0,10",
        "aspectPolarity": "Negative",
        "terms": [
          {
            "aspectTerm": "frequent uphill starts",
            "opinionTerm": "has a vague smell",
            "normedAspectTerm": "frequent uphill starts",
            "normedOpinionTerm": "has a vague smell"
          }
        ],
        "positiveProb": 0.003,
        "aspectCategory": "Odor/Smell",
        "negativeProb": 0.996
      },
      {
        "clause": "The reverse gear only engages after a full stop",
        "clauseIndex": "25,33",
        "aspectPolarity": "Negative",
        "terms": [
          {
            "aspectTerm": "reverse gear",
            "opinionTerm": "only engages after a full stop",
            "normedAspectTerm": "reverse gear",
            "normedOpinionTerm": "only engages after a full stop"
          }
        ],
        "positiveProb": 0.001,
        "aspectCategory": "Gear shifting",
        "negativeProb": 0.999
      }
    ],
    "textPolarity": "Negative"
  },
  "message": "SUCCESS",
  "tracerId": "1639036027.4482515"
}

Response parameters

Field

Description

textPolarity

The sentiment polarity of the entire text: Positive, Neutral, or Negative.

textProb

The confidence level of the sentiment polarity for the entire text. The value ranges from 0 to 1. A larger value indicates a higher probability that the text has the sentiment specified by textPolarity.

aspectItem

A list of aspect-sentiments. Each element is a JSON object.

aspectCategory

The aspect category.

aspectPolarity

The polarity of the aspect segment: Positive, Neutral, or Negative.

clause

The sentiment clause.

clauseIndex

The start and end positions of the sentiment clause.

positiveProb

The confidence level for positive sentiment. The value ranges from 0 to 1. A larger value indicates a higher probability of positive sentiment.

negativeProb

The confidence level for negative sentiment. The value ranges from 0 to 1. A larger value indicates a higher probability of negative sentiment.

terms

A list of extracted aspect-sentiment terms. Each element is a JSON object.

aspectTerm

Attribute

opinionTerm

Sentiment vocabulary

normedAspectTerm

The normalized aspect term.

normedOpinionTerm

The normalized opinion term.