Refact/fix ocr-fix-engine "check one letter word" - thx xylographe :)

Related to https://github.com/SubtitleEdit/subtitleedit/issues/3899#issuecomment-575968147 and #3899
This commit is contained in:
Nikolaj Olsson 2020-01-19 07:47:37 +01:00
parent 48d2e68215
commit 1e467be921
4 changed files with 14 additions and 10 deletions

View File

@ -91,7 +91,7 @@ namespace Nikse.SubtitleEdit.Core
public string MusicSymbolReplace { get; set; }
public string UnicodeSymbolsToInsert { get; set; }
public bool SpellCheckAutoChangeNames { get; set; }
public bool SpellCheckOneLetterWords { get; set; }
public bool CheckOneLetterWords { get; set; }
public bool SpellCheckEnglishAllowInQuoteAsIng { get; set; }
public bool RememberUseAlwaysList { get; set; }
public bool SpellCheckShowCompletedMessage { get; set; }
@ -287,7 +287,7 @@ namespace Nikse.SubtitleEdit.Core
GoogleApiV1ChunkSize = 1500;
GoogleTranslateLastTargetLanguage = "en";
TranslateAutoSplit = true;
SpellCheckOneLetterWords = true;
CheckOneLetterWords = true;
SpellCheckEnglishAllowInQuoteAsIng = false;
SpellCheckShowCompletedMessage = true;
ListViewSyntaxColorDurationSmall = true;
@ -2809,7 +2809,7 @@ $HorzAlign = Center
subNode = node.SelectSingleNode("SpellCheckOneLetterWords");
if (subNode != null)
{
settings.Tools.SpellCheckOneLetterWords = Convert.ToBoolean(subNode.InnerText);
settings.Tools.CheckOneLetterWords = Convert.ToBoolean(subNode.InnerText);
}
subNode = node.SelectSingleNode("SpellCheckEnglishAllowInQuoteAsIng");
@ -6425,7 +6425,7 @@ $HorzAlign = Center
textWriter.WriteElementString("MusicSymbolReplace", settings.Tools.MusicSymbolReplace);
textWriter.WriteElementString("UnicodeSymbolsToInsert", settings.Tools.UnicodeSymbolsToInsert);
textWriter.WriteElementString("SpellCheckAutoChangeNames", settings.Tools.SpellCheckAutoChangeNames.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SpellCheckOneLetterWords", settings.Tools.SpellCheckOneLetterWords.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SpellCheckOneLetterWords", settings.Tools.CheckOneLetterWords.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SpellCheckEnglishAllowInQuoteAsIng", settings.Tools.SpellCheckEnglishAllowInQuoteAsIng.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("RememberUseAlwaysList", settings.Tools.RememberUseAlwaysList.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SpellCheckShowCompletedMessage", settings.Tools.SpellCheckShowCompletedMessage.ToString(CultureInfo.InvariantCulture));

View File

@ -840,7 +840,7 @@ namespace Nikse.SubtitleEdit.Forms
checkBoxFixShortDisplayTimesAllowMoveStartTime.Checked = toolsSettings.FixShortDisplayTimesAllowMoveStartTime;
checkBoxFceSkipStep1.Checked = toolsSettings.FixCommonErrorsSkipStepOne;
checkBoxSpellCheckAutoChangeNames.Checked = toolsSettings.SpellCheckAutoChangeNames;
checkBoxSpellCheckOneLetterWords.Checked = toolsSettings.SpellCheckOneLetterWords;
checkBoxSpellCheckOneLetterWords.Checked = toolsSettings.CheckOneLetterWords;
checkBoxTreatINQuoteAsING.Checked = toolsSettings.SpellCheckEnglishAllowInQuoteAsIng;
checkBoxUseAlwaysToFile.Checked = toolsSettings.RememberUseAlwaysList;
checkBoxUseDoNotBreakAfterList.Checked = toolsSettings.UseNoLineBreakAfter;
@ -1634,7 +1634,7 @@ namespace Nikse.SubtitleEdit.Forms
toolsSettings.MusicSymbol = comboBoxToolsMusicSymbol.SelectedItem.ToString();
toolsSettings.MusicSymbolReplace = textBoxMusicSymbolsToReplace.Text;
toolsSettings.SpellCheckAutoChangeNames = checkBoxSpellCheckAutoChangeNames.Checked;
toolsSettings.SpellCheckOneLetterWords = checkBoxSpellCheckOneLetterWords.Checked;
toolsSettings.CheckOneLetterWords = checkBoxSpellCheckOneLetterWords.Checked;
toolsSettings.SpellCheckEnglishAllowInQuoteAsIng = checkBoxTreatINQuoteAsING.Checked;
toolsSettings.RememberUseAlwaysList = checkBoxUseAlwaysToFile.Checked;
toolsSettings.UseNoLineBreakAfter = checkBoxUseDoNotBreakAfterList.Checked;

View File

@ -557,7 +557,7 @@ namespace Nikse.SubtitleEdit.Forms
}
int minLength = 2;
if (Configuration.Settings.Tools.SpellCheckOneLetterWords)
if (Configuration.Settings.Tools.CheckOneLetterWords)
{
minLength = 1;
}

View File

@ -1300,7 +1300,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
}
int minLength = 2;
if (Configuration.Settings.Tools.SpellCheckOneLetterWords)
if (Configuration.Settings.Tools.CheckOneLetterWords)
{
minLength = 1;
}
@ -1324,7 +1324,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
if (!IsWordKnownOrNumber(word, line) && !localIgnoreWords.Contains(word))
{
var correct = false;
if (word.Length > minLength)
if (word.Length > 1)
{
if (_wordSpellOkList.Contains(word))
{
@ -1347,6 +1347,10 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
correct = DoSpell(word.TrimEnd('s'));
}
}
else
{
correct = !Configuration.Settings.Tools.CheckOneLetterWords; // hunspell allows too many single letter words
}
if (!correct && _userWordList.Contains(word))
{
@ -1900,7 +1904,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
}
int minLength = 2;
if (Configuration.Settings.Tools.SpellCheckOneLetterWords)
if (Configuration.Settings.Tools.CheckOneLetterWords)
{
minLength = 1;
}