@@ -34,6 +34,9 @@ class SyllableData {
3434}
3535
3636class PinyinUtils {
37+ static const String UNICODE_SQUARE = '⬜' ;
38+
39+ static final RegExp _unstarredTextRegexp = RegExp (r'[^*]+' );
3740 static final RegExp _punctuationRegex = RegExp (r"['!?.\[\],,。?!;:( )【 】[]]" );
3841 static const _allSyllables = [
3942 "zhuang" ,
@@ -646,6 +649,7 @@ class PinyinUtils {
646649 value,
647650 allPossibleSentences: allPossibleSentences,
648651 );
652+ // print(allPossibleSentences);
649653 if (allPossibleSentences.isNotEmpty) {
650654 _Sentence ? sentence;
651655 // print(allPossibleSentences);
@@ -902,10 +906,8 @@ class _Sentence {
902906 if (start < 0 ) {
903907 continue ;
904908 }
905- temp = temp.replaceFirst (
906- syl,
907- _getFiller (syl),
908- );
909+ final filler = _getFiller (syl);
910+ temp = temp.replaceFirst (syl, filler);
909911 final realSyllable = initialValue.substring (
910912 start,
911913 end,
@@ -922,6 +924,24 @@ class _Sentence {
922924 ),
923925 );
924926 }
927+ print (temp);
928+ final unstarred = PinyinUtils ._unstarredTextRegexp;
929+
930+ /// заменяет оставшиеся символы, которые не совпали с валидными слогами
931+ final matches = unstarred.allMatches (temp);
932+ for (var m in matches) {
933+ final text = temp.substring (m.start, m.end);
934+ _correctSequence! .add (
935+ SyllableData (
936+ value: text,
937+ tone: - 1 ,
938+ isValid: false ,
939+ start: m.start,
940+ end: m.end,
941+ ),
942+ );
943+ }
944+
925945 const invalidTone = - 1 ;
926946 _correctSequence! .sort ((a, b) => a.start.compareTo (b.start));
927947 final wrongSyllables = < SyllableData > [];
0 commit comments