相同语义判断 NLP
About 147 wordsLess than 1 minute
2024-11-7
开放平台为大家提供免费的 NLP
服务,用于判断两个文本是否为一个语义。如 开灯
= 帮我打开灯
。
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...
}