Do not ignore words of combined letters/numbers - thx Boulder08 :)

Work on #3183
This commit is contained in:
Nikolaj Olsson 2018-11-16 18:56:04 +01:00
parent 9d0a50def0
commit aa2296a500

View File

@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace Nikse.SubtitleEdit.Forms
@ -51,8 +52,6 @@ namespace Nikse.SubtitleEdit.Forms
private Main _mainWindow;
private string _currentDictionary;
private static readonly char[] ExpectedChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '%', '&', '@', '$', '*', '=', '£', '#', '_', '½', '^' };
public class SuggestionParameter
{
public string InputWord { get; set; }
@ -524,7 +523,7 @@ namespace Nikse.SubtitleEdit.Forms
if (Configuration.Settings.Tools.SpellCheckOneLetterWords)
minLength = 1;
if (_currentWord.Trim().Length >= minLength && !_currentWord.Contains(ExpectedChars))
if (_currentWord.Trim().Length >= minLength)
{
_prefix = string.Empty;
_postfix = string.Empty;
@ -555,6 +554,10 @@ namespace Nikse.SubtitleEdit.Forms
{
// "skip one" again (after change whole text)
}
else if (IsNumber(_currentWord))
{
_noOfSkippedWords++;
}
else if (_spellCheckWordLists.HasUserWord(_currentWord))
{
_noOfCorrectWords++;
@ -767,6 +770,17 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private static readonly Regex RegexIsNumber = new Regex("^\\d+$", RegexOptions.Compiled);
private static readonly Regex RegexIsEpisodeNumber = new Regex("^\\d+x\\d+$", RegexOptions.Compiled); // e.g. 12x02
private static bool IsNumber(string s)
{
s = s.Trim('$', '£');
if (RegexIsNumber.IsMatch(s))
return true;
if (RegexIsEpisodeNumber.IsMatch(s))
return true;
return false;
}
private void SetWords(string s)
{