From df72c62c577c9e46788b37c89aa35ead07e05a8c Mon Sep 17 00:00:00 2001 From: Ivandro Ismael Date: Wed, 7 Sep 2016 03:00:22 +0100 Subject: [PATCH] [OcrEngine] - init hashsets in one run. --- src/Logic/OCR/OcrFixEngine.cs | 40 ++++++++++++++++------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/Logic/OCR/OcrFixEngine.cs b/src/Logic/OCR/OcrFixEngine.cs index 0c40307a8..a1a9e4376 100644 --- a/src/Logic/OCR/OcrFixEngine.cs +++ b/src/Logic/OCR/OcrFixEngine.cs @@ -208,33 +208,27 @@ namespace Nikse.SubtitleEdit.Logic.Ocr _namesEtcList = _namesList.GetNames(); _namesEtcMultiWordList = _namesList.GetMultiNames(); _namesEtcListUppercase = new HashSet(); - foreach (string name in _namesEtcList) - _namesEtcListUppercase.Add(name.ToUpper()); - _namesEtcListWithApostrophe = new HashSet(); - if (threeLetterIsoLanguageName.Equals("eng", StringComparison.OrdinalIgnoreCase)) + _abbreviationList = new HashSet(); + + bool isEnglish = threeLetterIsoLanguageName.Equals("eng", StringComparison.OrdinalIgnoreCase); + foreach (string name in _namesEtcList) { - foreach (string namesItem in _namesEtcList) + _namesEtcListUppercase.Add(name.ToUpper()); + if (isEnglish) { - if (!namesItem.EndsWith('s')) - _namesEtcListWithApostrophe.Add(namesItem + "'s"); + if (!name.EndsWith('s')) + _namesEtcListWithApostrophe.Add(name + "'s"); else - _namesEtcListWithApostrophe.Add(namesItem + "'"); + _namesEtcListWithApostrophe.Add(name + "'"); + } + // Abbreviations. + if (name.EndsWith('.')) + { + _abbreviationList.Add(name); } } - - // Load user words - _userWordList = new HashSet(); - _userWordListXmlFileName = Utilities.LoadUserWordList(_userWordList, _fiveLetterWordListLanguageName); - - // Find abbreviations - _abbreviationList = new HashSet(); - foreach (string name in _namesEtcList) - { - if (name.EndsWith('.')) - _abbreviationList.Add(name); - } - if (threeLetterIsoLanguageName.Equals("eng", StringComparison.OrdinalIgnoreCase)) + if (isEnglish) { if (!_abbreviationList.Contains("a.m.")) _abbreviationList.Add("a.m."); @@ -243,7 +237,9 @@ namespace Nikse.SubtitleEdit.Logic.Ocr if (!_abbreviationList.Contains("o.r.")) _abbreviationList.Add("o.r."); } - + // Load user words + _userWordList = new HashSet(); + _userWordListXmlFileName = Utilities.LoadUserWordList(_userWordList, _fiveLetterWordListLanguageName); foreach (string name in _userWordList) { if (name.EndsWith('.'))