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;
}
Aggregations