spell check will now accept names with ending with "'s" automatically (English languages only)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@252 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-01-15 13:01:17 +00:00
parent c5e216b396
commit 15970a7274
2 changed files with 40 additions and 1 deletions

View File

@ -28,6 +28,7 @@ namespace Nikse.SubtitleEdit.Forms
List<string> _namesEtcList = new List<string>();
List<string> _namesEtcMultiWordList = new List<string>();
List<string> _namesEtcListUppercase = new List<string>();
List<string> _namesEtcListWithApostrophe = new List<string>();
List<string> _skipAllList = new List<string>();
Dictionary<string, string> _changeAllDictionary = new Dictionary<string, string>();
List<string> _userWordList = new List<string>();
@ -371,6 +372,10 @@ namespace Nikse.SubtitleEdit.Forms
{
_namesEtcList.Add(_currentWord);
_namesEtcListUppercase.Add(_currentWord.ToUpper());
if (!_currentWord.EndsWith("s"))
_namesEtcListWithApostrophe.Add(_currentWord + "'s");
else
_namesEtcListWithApostrophe.Add(_currentWord + "'");
Utilities.AddWordToLocalNamesEtcList(_currentWord, _languageName);
}
else
@ -378,6 +383,8 @@ namespace Nikse.SubtitleEdit.Forms
if (!_namesEtcList.Contains(ChangeWord))
Utilities.AddWordToLocalNamesEtcList(ChangeWord, _languageName);
_namesEtcListUppercase.Add(ChangeWord.ToUpper());
_namesEtcListUppercase.Add(_currentWord.ToUpper());
if (!_currentWord.EndsWith("s"))
_noOfChangedWords++;
if (!_changeAllDictionary.ContainsKey(_currentWord))
_changeAllDictionary.Add(_currentWord, ChangeWord);
@ -508,6 +515,10 @@ namespace Nikse.SubtitleEdit.Forms
{
_noOfNamesEtc++;
}
else if (_namesEtcListWithApostrophe.IndexOf(_currentWord) >= 0)
{
_noOfNamesEtc++;
}
else if (Utilities.IsInNamesEtcMultiWordList(_namesEtcMultiWordList, _currentParagraph.Text, _currentWord)) //TODO: verify this!
{
_noOfNamesEtc++;
@ -597,6 +608,7 @@ namespace Nikse.SubtitleEdit.Forms
_namesEtcList = new List<string>();
_namesEtcMultiWordList = new List<string>();
_namesEtcListUppercase = new List<string>();
_namesEtcListWithApostrophe = new List<string>();
_skipAllList = new List<string>();
@ -636,6 +648,17 @@ namespace Nikse.SubtitleEdit.Forms
foreach (string namesItem in _namesEtcList)
_namesEtcListUppercase.Add(namesItem.ToUpper());
if (_languageName.ToLower().StartsWith("en_"))
{
foreach (string namesItem in _namesEtcList)
{
if (!namesItem.EndsWith("s"))
_namesEtcListWithApostrophe.Add(namesItem + "'s");
else
_namesEtcListWithApostrophe.Add(namesItem + "'");
}
}
_userWordList = new List<string>();
_userWordDictionary = new XmlDocument();
if (File.Exists(dictionaryFolder + _languageName + "_user.xml"))

View File

@ -26,6 +26,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR
string _fiveLetterWordListLanguageName;
List<string> _namesEtcList = new List<string>();
List<string> _namesEtcListUppercase = new List<string>();
List<string> _namesEtcListWithApostrophe = new List<string>();
List<string> _namesEtcMultiWordList = new List<string>(); // case sensitive phrases
List<string> _abbreviationList;
List<string> _userWordList = new List<string>();
@ -138,6 +139,18 @@ namespace Nikse.SubtitleEdit.Logic.OCR
foreach (string name in _namesEtcList)
_namesEtcListUppercase.Add(name.ToUpper());
_namesEtcListWithApostrophe = new List<string>();
if (threeLetterIsoLanguageName.ToLower() == "eng")
{
foreach (string namesItem in _namesEtcList)
{
if (!namesItem.EndsWith("s"))
_namesEtcListWithApostrophe.Add(namesItem + "'s");
else
_namesEtcListWithApostrophe.Add(namesItem + "'");
}
}
// Load user words
_userWordList = new List<string>();
_userWordListXmlFileName = Utilities.LoadUserWordList(_userWordList, _fiveLetterWordListLanguageName);
@ -978,6 +991,9 @@ namespace Nikse.SubtitleEdit.Logic.OCR
if (word.Length > 2 && _namesEtcListUppercase.IndexOf(word) >= 0)
return true;
if (word.Length > 2 && _namesEtcListWithApostrophe.IndexOf(word) >= 0)
return true;
if (Utilities.IsInNamesEtcMultiWordList(_namesEtcMultiWordList, line, word))
return true;