Sentiment Analysis (Domain-specific Edition)
- Example request
//You are advised to construct and use the client in a singleton pattern to avoid frequent object creation. NluClient client = new NluClient (AuthMode.AKSK,authInfo); GeneralSentimentReq req = new GeneralSentimentReq(); req.setContent("Text for analysis"); //Domain type. SentimentDomainConstant.DOMAIN_TYPE_CAR indicates the automotive domain. The value is 2. //SentimentDomainConstant.DOMAIN_TYPE_E_COMMERCE indicates the e-commerce domain. The value is 1. req.setType(SentimentDomainConstant.DOMAIN_TYPE_CAR); try { GeneralSentimentResp resp = client.getDomainSentiment(req); } catch (NlpException e) { //A failure is thrown as an exception. For details about exceptions, see section "Exceptions". The client automatically processes exceptions. }
- Table 1 describes GeneralSentimentReq parameters.
Table 1 GeneralSentimentReq parameters Parameter
Mandatory
Type
Description
content
Yes
String
Text to be analyzed. The text must be encoded using UTF-8. Only Chinese text sentiment analysis is supported. If type is set to 1 (e-commerce), the value contains a maximum of 200 characters. If the value exceeds 200 characters, only the first 200 characters are detected. If type is set to 2 (automotive), the value contains a maximum of 400 characters. If the value exceeds 400 characters, only the first 400 characters are detected.
type
No
Integer
The options are as follows:
1: E-commerce comments
2: Automotive comments
- Table 2 describes GeneralSentimentResp parameters.
- Table 3 describes the data structure description of the Result field.
Last Article: Sentiment Analysis (Basic Edition)
Next Article: Text Classification
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.