Text Classification
- 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); ClassifyReq req = new ClassifyReq(); req.setContent("Text for classification"); //Classified domain type. ClassifyDomainConstant.DOMAIN_TYPE_AD indicates advertisement and its value is 1. Currently, only the advertisement type is supported. req.setDomain(ClassifyDomainConstant.DOMAIN_TYPE_AD); try { ClassifyResp resp = client.classifyText(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 ClassifyReq parameters.
Table 1 ClassifyReq parameters Parameter
Mandatory
Type
Description
content
Yes
String
Text to be analyzed. The text is encoded using UTF-8 and the value contains a maximum of 400 characters. If the value exceeds 400 characters, only the first 400 characters are detected.
domain
No
Integer
The default value is 1. Currently, only advertisement detection is supported.
1: Advertisement detection
- Table 2 describes ClassifyResp parameters.
- Table 3 describes the data structure description of the Result field.
Last Article: Sentiment Analysis (Domain-specific Edition)
Next Article: Intent Understanding
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.