调整
This commit is contained in:
parent
851b259f81
commit
91985fd241
@ -1,5 +1,7 @@
|
|||||||
package club.joylink.rtss.services.voice.discriminate;
|
package club.joylink.rtss.services.voice.discriminate;
|
||||||
|
|
||||||
|
import club.joylink.rtss.exception.BusinessException;
|
||||||
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.services.voice.VoiceService;
|
import club.joylink.rtss.services.voice.VoiceService;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
import club.joylink.rtss.simulation.cbtc.discriminate.ParamExtractResult;
|
import club.joylink.rtss.simulation.cbtc.discriminate.ParamExtractResult;
|
||||||
@ -9,6 +11,8 @@ import club.joylink.rtss.simulation.cbtc.discriminate.VoiceDiscriminateRule;
|
|||||||
import club.joylink.rtss.util.PinYinUtil;
|
import club.joylink.rtss.util.PinYinUtil;
|
||||||
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
|
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
|
||||||
import club.joylink.rtss.vo.client.voice.VoiceRecognitionVO;
|
import club.joylink.rtss.vo.client.voice.VoiceRecognitionVO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@ -24,6 +28,7 @@ import java.util.regex.Pattern;
|
|||||||
* 语音文件解析服务
|
* 语音文件解析服务
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class VoiceParseServiceImpl implements VoiceParseService {
|
public class VoiceParseServiceImpl implements VoiceParseService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,26 +133,23 @@ public class VoiceParseServiceImpl implements VoiceParseService {
|
|||||||
List<ParamExtractRule> paramsRules = result.getRule().getParamsRules();
|
List<ParamExtractRule> paramsRules = result.getRule().getParamsRules();
|
||||||
List<ParamExtractResult> paramExtractResults = new ArrayList<>(paramsRules.size());
|
List<ParamExtractResult> paramExtractResults = new ArrayList<>(paramsRules.size());
|
||||||
int groupSize = result.getGroupCount();
|
int groupSize = result.getGroupCount();
|
||||||
// ParamExtractResult extractResult = null;
|
|
||||||
// String[] originGroupArr = null, correctGroupArr = null;
|
|
||||||
for (ParamExtractRule rule : paramsRules) {
|
for (ParamExtractRule rule : paramsRules) {
|
||||||
String[] originGroupArr = null, correctGroupArr = null;
|
if(ArrayUtils.isEmpty(rule.getIndexArr())){
|
||||||
if (rule.getIndexArr() != null) { // 如果定位信息不为空
|
log.error("参数解析配置数据错误原文:[{}],匹配规则:[{}]",result.getOriginContent(),result.getRule().getKeyWordRules());
|
||||||
originGroupArr = new String[rule.getIndexArr().length];
|
throw new BusinessException(BusinessExceptionAssertEnum.VOICE_COMMAND_CONFIG_NULL);
|
||||||
correctGroupArr = new String[rule.getIndexArr().length];
|
}
|
||||||
for (int index = 0, len = originGroupArr.length; index < len; index ++) {
|
String[] originGroupArr = new String[rule.getIndexArr().length];
|
||||||
if (groupSize < rule.getIndexArr()[index]) {
|
String[] correctGroupArr = new String[rule.getIndexArr().length];
|
||||||
result.setSuccess(false);
|
for (int index = 0, len = originGroupArr.length; index < len; index ++) {
|
||||||
result.setMsg("提取参数出错");
|
if (groupSize < rule.getIndexArr()[index]) {
|
||||||
return;
|
result.setSuccess(false);
|
||||||
}
|
result.setMsg("提取参数出错");
|
||||||
originGroupArr[index] = result.getGroup(rule.getIndexArr()[index]);
|
return;
|
||||||
correctGroupArr[index] = result.getCorrectGroup(rule.getIndexArr()[index]);
|
|
||||||
}
|
}
|
||||||
} /*else { // 如果定位信息为空,则将参数置空
|
Integer paramIndex = rule.getIndexArr()[index];
|
||||||
originGroupArr = null;
|
originGroupArr[index] = result.getGroup(paramIndex);
|
||||||
correctGroupArr = null;
|
correctGroupArr[index] = result.getCorrectGroup(paramIndex);
|
||||||
}*/
|
}
|
||||||
ParamExtractResult extractResult = rule.getParseRule().matchParam(simulation, originGroupArr, correctGroupArr);
|
ParamExtractResult extractResult = rule.getParseRule().matchParam(simulation, originGroupArr, correctGroupArr);
|
||||||
paramExtractResults.add(extractResult);
|
paramExtractResults.add(extractResult);
|
||||||
// 对已纠正过的数据进行记录
|
// 对已纠正过的数据进行记录
|
||||||
|
Loading…
Reference in New Issue
Block a user