同義判断NLP
127字程度1分以内
2024-11-7
オープンプラットフォームは、2つのテキストが同じ意味であるかどうかを判断するために使用される無素材の NLPサービスをすべての人に提供されます。たとえば、开灯 = 帮我打开灯 となります。
::: コードタブ @tab Nodejs
const axios = require('axios');
const api_key = "开放平台 api_key";
// AI 推理
const response = await axios.post(item.nlp_server || `https://api.espai.fun/ai_api/semantic`, {
"api_key": api_key,
"texts": ["开灯", "帮我打开灯"] // 服务会推理两个句子是否是一个语义
}, { headers: { 'Content-Type': 'application/json' } });
const { success, message: res_msg, data } = response.data;
if (!success) {
// 失败处理...
return;
}
if (data === true) {
// 语义相同
// some code...
}else{
// 语义不相同
// some code...
}
