From f38c3bd1ba5bd99596bb5d132e2af978239edaf0 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 11 Apr 2023 14:00:43 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E8=AF=AD=E9=9F=B3?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E5=AD=97=E7=AC=A6=E5=8C=B9=E9=85=8D=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E4=BD=8D=E7=BD=AE=E7=B4=A2=E5=BC=95=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/discriminate/VoiceDiscriminateResult.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/discriminate/VoiceDiscriminateResult.java b/src/main/java/club/joylink/rtss/simulation/cbtc/discriminate/VoiceDiscriminateResult.java index 9a70794fd..d64d1309c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/discriminate/VoiceDiscriminateResult.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/discriminate/VoiceDiscriminateResult.java @@ -122,16 +122,16 @@ public class VoiceDiscriminateResult { String pinYin = null; for (int i = 0, len = contentPinYinArr.length; i < len; i ++) { pinYin = contentPinYinArr[i]; - if (Objects.equals(group.substring(readIndex, readIndex + pinYin.length()), pinYin)) { - if (readIndex == 0) { + if (Objects.equals(group.substring(readIndex, readIndex + pinYin.length()), pinYin)) { // 字符一致 + if (readIndex == 0) { // 如果是0代表刚开始匹配,记录开始索引 indexArr[0] = i; } readIndex = readIndex + pinYin.length(); - } else { + } else { // 字符不一致,重新匹配位置 readIndex = 0; } if (readIndex == group.length()) { // 结束位置 - indexArr[1] = i + 1; + indexArr[1] = i; break; } }