文本替换添加对应的日志

This commit is contained in:
tiger_zhou 2024-03-11 17:57:12 +08:00
parent c085f5f778
commit d20fe5fd27
1 changed files with 206 additions and 204 deletions

View File

@ -18,7 +18,7 @@ public class SimulationVoiceHandler {
static Map<String, String> regexReplaceMap = new HashMap<>();
// static {
// static {
// regexReplaceMap.put("", "1");
// }
static List<Replacement> numReplacementList;
@ -147,6 +147,7 @@ public class SimulationVoiceHandler {
* 匹配替换对象
*/
public static class Replacement {
String match;
String replace;
@ -163,12 +164,13 @@ public class SimulationVoiceHandler {
}
}
public String numHandle(String content){
public String numHandle(String content) {
for (Replacement replacement : numReplacementList) {
content = replacement.matchAndReplace(content);
}
return regexReplace(content);
}
/**
* 对语音识别内容进行仿真用词处理
*
@ -183,7 +185,7 @@ public class SimulationVoiceHandler {
}
private String regexReplace(String s) {
log.info("正则替换");
log.info("正则替换 字符[{}]", s);
//编号替换
Pattern pattern = Pattern.compile("([一二三四五六七八九十]+)(号)");
Matcher matcher = pattern.matcher(s);