diff --git a/iot-common/iot-third/pom.xml b/iot-common/iot-third/pom.xml
index aae5f93..4b05594 100644
--- a/iot-common/iot-third/pom.xml
+++ b/iot-common/iot-third/pom.xml
@@ -80,6 +80,13 @@
spring-cloud-context
+
+
+ com.belerweb
+ pinyin4j
+ 2.5.1
+
+
diff --git a/iot-common/iot-third/src/main/java/com/qiuguo/iot/third/service/NlpService.java b/iot-common/iot-third/src/main/java/com/qiuguo/iot/third/service/NlpService.java
index 43321be..269b6c0 100644
--- a/iot-common/iot-third/src/main/java/com/qiuguo/iot/third/service/NlpService.java
+++ b/iot-common/iot-third/src/main/java/com/qiuguo/iot/third/service/NlpService.java
@@ -14,6 +14,9 @@ import com.qiuguo.iot.third.nlp.action.Action;
import com.qiuguo.iot.third.nlp.action.Actions;
import com.qiuguo.iot.third.nlp.entity.SystemTalkKeyAndDeviceName;
import lombok.extern.slf4j.Slf4j;
+import net.sourceforge.pinyin4j.PinyinHelper;
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
+import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
@@ -51,6 +54,8 @@ public class NlpService {
List systemIncluds = new ArrayList<>();
List systemTalkKeyAndDeviceNameList = new ArrayList<>();
+
+
int i = 0;
for(SystemTalkAnswerConfigEntity entity : systemTalkAnswerConfigService.getCommandList()){
SystemTalkKeyAndDeviceName systemTalkKeyAndDeviceName = new SystemTalkKeyAndDeviceName();
@@ -82,6 +87,7 @@ public class NlpService {
String pText = text;
i = 0;
int j = 0;
+ Boolean isFinding = false;
for(SystemTalkKeyAndDeviceName sysTalkKeyAndDeviceName :systemTalkKeyAndDeviceNameList){
if(pText.indexOf(sysTalkKeyAndDeviceName.getKey()) >= 0){
//找到对应的名称
@@ -89,10 +95,12 @@ public class NlpService {
//用户绑定设备名称
pText = pText.replace(sysTalkKeyAndDeviceName.getKey(), ">" + (i++) + ">");
includs.add(deviceUserBindEntityPagerResult.getData().get(sysTalkKeyAndDeviceName.getIndex()));
+ isFinding = true;
}else{// if(sysTalkKeyAndDeviceName.getType().equals(KeyTypeEnum.SYSTEM_COMMAND.getCode())){
//是系统自定义动词后的名称
pText = pText.replace(sysTalkKeyAndDeviceName.getKey(), "#" + (j++) + "#");
systemIncluds.add(systemTalkAnswerConfigService.getCommandList().get(sysTalkKeyAndDeviceName.getIndex()));
+ isFinding = true;
}/*else{
//秋果专有名称
pText = pText.replace(sysTalkKeyAndDeviceName.getKey(), "<" + (j++) + "<");
@@ -100,6 +108,25 @@ public class NlpService {
}*/
}
}
+ if(!isFinding){
+ HanyuPinyinOutputFormat hanyuPinyinOutputFormat = new HanyuPinyinOutputFormat();
+ hanyuPinyinOutputFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+ try {
+ String pinyinArray = PinyinHelper.toHanYuPinyinString(text, hanyuPinyinOutputFormat, null, false).replaceAll("null", "");
+ log.info("拼音结果:{}", pinyinArray);
+ for(SystemTalkKeyAndDeviceName sysTalkKeyAndDeviceName :systemTalkKeyAndDeviceNameList){
+ if(pinyinArray.indexOf(sysTalkKeyAndDeviceName.getKey()) >= 0){
+ if(sysTalkKeyAndDeviceName.getType().equals(KeyTypeEnum.QIUGUO_NAME.getCode())){
+ pinyinArray = pinyinArray.replace(sysTalkKeyAndDeviceName.getKey(), "#" + (j++) + "#");
+ systemIncluds.add(systemTalkAnswerConfigService.getCommandList().get(sysTalkKeyAndDeviceName.getIndex()));
+ return getActions(pinyinArray, text, includs, systemIncluds, type);
+ }
+ }
+ }
+ }catch (Exception e) {
+ log.info("获取拼音异常");
+ }
+ }
return getActions(pText, text, includs, systemIncluds, type);
});
@@ -110,6 +137,7 @@ public class NlpService {
List includs,
List commands,
String type) {
+
return liguoNlpService.geSingletNlp(text, type).map(nlp -> {
Actions actions = new Actions();
actions.setActions(new ArrayList<>());
diff --git a/iot-modules/iot-box-websocket-api/pom.xml b/iot-modules/iot-box-websocket-api/pom.xml
index d9ba428..2e06c5e 100644
--- a/iot-modules/iot-box-websocket-api/pom.xml
+++ b/iot-modules/iot-box-websocket-api/pom.xml
@@ -94,6 +94,8 @@
4.6.4
+
+