Expose NeutralSentenceEndingChars and optimize method in FixCommas

Make NeutralSentenceEndingChars publicly accessible by changing its access modifier to public. Also, refactor the IsNextCharSentenceClosingSymbol method in FixCommas to utilize the NeutralSentenceEndingChars for more concise and efficient logic.

Signed-off-by: Ivandro Jao <Ivandrofly@gmail.com>
This commit is contained in:
Ivandro Jao 2024-11-03 12:10:26 +00:00
parent dedbe0b878
commit b91a281e85
2 changed files with 3 additions and 8 deletions

View File

@ -771,7 +771,7 @@ namespace Nikse.SubtitleEdit.Core.Common
return value.HasSentenceEnding(string.Empty);
}
private static readonly HashSet<char> NeutralSentenceEndingChars = new HashSet<char>
public static readonly IReadOnlyCollection<char> NeutralSentenceEndingChars = new HashSet<char>
{
'.', '!', '?', ']', ')', '…', '♪', '؟', '。', ''
};

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Nikse.SubtitleEdit.Core.Interfaces;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core.Common;
@ -98,13 +99,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
bool IsNextCharSentenceClosingSymbol(int index, char[] characters)
{
if (index + 1 < characters.Length)
{
var nextChar = characters[index + 1];
return nextChar == '.' || nextChar == '?' || nextChar == '!' || nextChar == ')' || nextChar == ']' || nextChar == '؟';
}
return false;
return index + 1 < characters.Length && StringExtensions.NeutralSentenceEndingChars.Contains(characters[index + 1]);
}
}
}