Text Similarity
- Example request
//You are advised to construct and use the client in a singleton pattern to avoid frequent object creation. NlpfClient client = new NlpfClient(AuthMode.AKSK,authInfo); TextSimilarityReq req = new TextSimilarityReq(); //Two texts for similarity comparison req.setText1("text-1"); req.setText2("text-2"); //Supported language of the text. The default value is zh, indicating Chinese. Only Chinese is currently supported. req.setLang("zh"); try { TextSimilarityResp resp = client.getTextSimilarity(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 TextSimilarityReq parameters.
Table 1 TextSimilarityReq parameters Parameter
Mandatory
Type
Description
text1
Yes
String
Text 1, on which the text similarity is to be computed. The text is encoded using UTF-8 and contains 1 to 512 characters.
text2
Yes
String
Text 2, on which the text similarity is to be computed. The text is encoded using UTF-8 and contains 1 to 512 characters.
lang
No
String
Supported text language type. The default value is zh. Currently, only Chinese is supported.
- Table 2 describes TextSimilarityResp parameters.
Last Article: NER (Domain-specific Edition)
Next Article: Sentence Vector
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.