mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Fixed bug in OCR-add-to-user-dictionary
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@95 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
12b039b55f
commit
abd3fbfc37
@ -23,7 +23,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR
|
|||||||
Dictionary<string, string> _partialWordReplaceList;
|
Dictionary<string, string> _partialWordReplaceList;
|
||||||
string _replaceListXmlFileName;
|
string _replaceListXmlFileName;
|
||||||
string _userWordListXmlFileName;
|
string _userWordListXmlFileName;
|
||||||
string _languageName;
|
string _fiveLetterWordListLanguageName;
|
||||||
List<string> _namesEtcList = new List<string>();
|
List<string> _namesEtcList = new List<string>();
|
||||||
List<string> _namesEtcListUppercase = new List<string>();
|
List<string> _namesEtcListUppercase = new List<string>();
|
||||||
List<string> _namesEtcMultiWordList = new List<string>(); // case sensitive phrases
|
List<string> _namesEtcMultiWordList = new List<string>(); // case sensitive phrases
|
||||||
@ -90,7 +90,6 @@ namespace Nikse.SubtitleEdit.Logic.OCR
|
|||||||
{
|
{
|
||||||
if (culture.ThreeLetterISOLanguageName == threeLetterIsoLanguageName)
|
if (culture.ThreeLetterISOLanguageName == threeLetterIsoLanguageName)
|
||||||
{
|
{
|
||||||
_languageName = culture.TwoLetterISOLanguageName;
|
|
||||||
string dictionaryFolder = Utilities.DictionaryFolder;
|
string dictionaryFolder = Utilities.DictionaryFolder;
|
||||||
if (!Directory.Exists(dictionaryFolder))
|
if (!Directory.Exists(dictionaryFolder))
|
||||||
return;
|
return;
|
||||||
@ -99,8 +98,8 @@ namespace Nikse.SubtitleEdit.Logic.OCR
|
|||||||
if (files.Length == 0)
|
if (files.Length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string languageName = Path.GetFileName(files[0]).Substring(0, 5);
|
_fiveLetterWordListLanguageName = Path.GetFileName(files[0]).Substring(0, 5);
|
||||||
string dictionary = Utilities.DictionaryFolder + languageName;
|
string dictionary = Utilities.DictionaryFolder + _fiveLetterWordListLanguageName;
|
||||||
_wordSkipList = new List<string>();
|
_wordSkipList = new List<string>();
|
||||||
_wordSkipList.Add(Configuration.Settings.Tools.MusicSymbol);
|
_wordSkipList.Add(Configuration.Settings.Tools.MusicSymbol);
|
||||||
_wordSkipList.Add("*");
|
_wordSkipList.Add("*");
|
||||||
@ -111,7 +110,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR
|
|||||||
// Load names etc list (names/noise words)
|
// Load names etc list (names/noise words)
|
||||||
_namesEtcList = new List<string>();
|
_namesEtcList = new List<string>();
|
||||||
_namesEtcMultiWordList = new List<string>();
|
_namesEtcMultiWordList = new List<string>();
|
||||||
Utilities.LoadNamesEtcWordLists(_namesEtcList, _namesEtcMultiWordList, languageName);
|
Utilities.LoadNamesEtcWordLists(_namesEtcList, _namesEtcMultiWordList, _fiveLetterWordListLanguageName);
|
||||||
|
|
||||||
_namesEtcListUppercase = new List<string>();
|
_namesEtcListUppercase = new List<string>();
|
||||||
foreach (string name in _namesEtcList)
|
foreach (string name in _namesEtcList)
|
||||||
@ -119,7 +118,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR
|
|||||||
|
|
||||||
// Load user words
|
// Load user words
|
||||||
_userWordList = new List<string>();
|
_userWordList = new List<string>();
|
||||||
_userWordListXmlFileName = Utilities.LoadUserWordList(_userWordList, languageName);
|
_userWordListXmlFileName = Utilities.LoadUserWordList(_userWordList, _fiveLetterWordListLanguageName);
|
||||||
|
|
||||||
// Load NHunspell spellchecker
|
// Load NHunspell spellchecker
|
||||||
_hunspell = new Hunspell(dictionary + ".aff", dictionary + ".dic");
|
_hunspell = new Hunspell(dictionary + ".aff", dictionary + ".dic");
|
||||||
@ -558,7 +557,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR
|
|||||||
if (_hunspell == null)
|
if (_hunspell == null)
|
||||||
return line;
|
return line;
|
||||||
|
|
||||||
string[] words = line.Split((Environment.NewLine + " ,.!?:;()[]{}+-$£\"“#&%").ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
string[] words = line.Split((Environment.NewLine + " ,.!?:;()[]{}+-$£\"”“#&%").ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||||
for (int i = 0; i < words.Length; i++)
|
for (int i = 0; i < words.Length; i++)
|
||||||
{
|
{
|
||||||
string word = words[i];
|
string word = words[i];
|
||||||
@ -638,7 +637,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR
|
|||||||
if (_userWordListXmlFileName != null)
|
if (_userWordListXmlFileName != null)
|
||||||
{
|
{
|
||||||
_userWordList.Add(_spellCheck.Word);
|
_userWordList.Add(_spellCheck.Word);
|
||||||
Utilities.AddToUserDictionary(_spellCheck.Word, _languageName);
|
Utilities.AddToUserDictionary(_spellCheck.Word, _fiveLetterWordListLanguageName);
|
||||||
}
|
}
|
||||||
result.Word = _spellCheck.Word;
|
result.Word = _spellCheck.Word;
|
||||||
result.Fixed = true;
|
result.Fixed = true;
|
||||||
@ -656,7 +655,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR
|
|||||||
_namesEtcMultiWordList.Add(s);
|
_namesEtcMultiWordList.Add(s);
|
||||||
else
|
else
|
||||||
_namesEtcList.Add(s);
|
_namesEtcList.Add(s);
|
||||||
Utilities.AddWordToLocalNamesEtcList(s, _languageName);
|
Utilities.AddWordToLocalNamesEtcList(s, _fiveLetterWordListLanguageName);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user