Search in sources :

Example 1 with SensitiveWordsRecognitionResponse

use of com.tencentcloudapi.nlp.v20190408.models.SensitiveWordsRecognitionResponse in project cloud-sdk by mizhousoft.

the class SensitiveWordsRecognitionServiceImpl method recognizeOne.

public RecognitionResult recognizeOne(String text) throws CloudSDKException {
    RecognitionResult result = new RecognitionResult();
    if (StringUtils.isBlank(text)) {
        return result;
    }
    try {
        SensitiveWordsRecognitionRequest request = new SensitiveWordsRecognitionRequest();
        request.setText(text);
        SensitiveWordsRecognitionResponse resp = nlpClient.SensitiveWordsRecognition(request);
        String[] words = resp.getSensitiveWords();
        if (!ArrayUtils.isEmpty(words)) {
            result.setSensitiveWords(Arrays.asList(words));
        }
    } catch (TencentCloudSDKException e) {
        throw new CloudSDKException(e.getMessage(), e);
    }
    return result;
}
Also used : TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) SensitiveWordsRecognitionRequest(com.tencentcloudapi.nlp.v20190408.models.SensitiveWordsRecognitionRequest) SensitiveWordsRecognitionResponse(com.tencentcloudapi.nlp.v20190408.models.SensitiveWordsRecognitionResponse) RecognitionResult(com.mizhousoft.cloudsdk.nlp.RecognitionResult)

Aggregations

CloudSDKException (com.mizhousoft.cloudsdk.CloudSDKException)1 RecognitionResult (com.mizhousoft.cloudsdk.nlp.RecognitionResult)1 TencentCloudSDKException (com.tencentcloudapi.common.exception.TencentCloudSDKException)1 SensitiveWordsRecognitionRequest (com.tencentcloudapi.nlp.v20190408.models.SensitiveWordsRecognitionRequest)1 SensitiveWordsRecognitionResponse (com.tencentcloudapi.nlp.v20190408.models.SensitiveWordsRecognitionResponse)1