Minor fix in "Fix common ocr errors" for italic lines starting with "Io " - thx matidio :)

This commit is contained in:
niksedk 2014-05-11 18:24:09 +02:00
parent 93feb8a4f9
commit f1438f286a
2 changed files with 9 additions and 8 deletions

View File

@ -3903,8 +3903,8 @@ namespace Nikse.SubtitleEdit.Forms
{
line = threadText;
}
if (checkBoxAutoFixCommonErrors.Checked)
line = OcrFixEngine.FixOcrErrorsViaHardcodedRules(line, _lastLine, null); // TODO: add abbreviations list
if (checkBoxAutoFixCommonErrors.Checked && _ocrFixEngine != null)
line = _ocrFixEngine.FixOcrErrorsViaHardcodedRules(line, _lastLine, null); // TODO: add abbreviations list
if (checkBoxRightToLeft.Checked)
line = ReverseNumberStrings(line);
@ -4109,8 +4109,8 @@ namespace Nikse.SubtitleEdit.Forms
{
line = threadText;
}
if (checkBoxAutoFixCommonErrors.Checked)
line = OcrFixEngine.FixOcrErrorsViaHardcodedRules(line, _lastLine, null); // TODO: add abbreviations list
if (checkBoxAutoFixCommonErrors.Checked && _ocrFixEngine != null)
line = _ocrFixEngine.FixOcrErrorsViaHardcodedRules(line, _lastLine, null); // TODO: add abbreviations list
if (checkBoxRightToLeft.Checked)
line = ReverseNumberStrings(line);
@ -4606,8 +4606,8 @@ namespace Nikse.SubtitleEdit.Forms
line = line.Replace("9-O", "9-0");
}
if (checkBoxAutoFixCommonErrors.Checked)
line = OcrFixEngine.FixOcrErrorsViaHardcodedRules(line, _lastLine, null); // TODO: add abbreviations list
if (checkBoxAutoFixCommonErrors.Checked && _ocrFixEngine != null)
line = _ocrFixEngine.FixOcrErrorsViaHardcodedRules(line, _lastLine, null); // TODO: add abbreviations list
if (checkBoxRightToLeft.Checked)
line = ReverseNumberStrings(line);

View File

@ -1116,7 +1116,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR
return false;
}
public static string FixOcrErrorsViaHardcodedRules(string input, string lastLine, HashSet<string> abbreviationList)
public string FixOcrErrorsViaHardcodedRules(string input, string lastLine, HashSet<string> abbreviationList)
{
if (!Configuration.Settings.Tools.OcrFixUseHardcodedRules)
return input;
@ -1227,7 +1227,6 @@ namespace Nikse.SubtitleEdit.Logic.OCR
input = input.Insert(idx + Environment.NewLine.Length + 4, " ");
}
if (string.IsNullOrEmpty(lastLine) ||
lastLine.EndsWith(".") ||
lastLine.EndsWith("!") ||
@ -1244,6 +1243,8 @@ namespace Nikse.SubtitleEdit.Logic.OCR
string uppercaseLetter = st.StrippedText[0].ToString().ToUpper();
if (st.StrippedText.Length > 1 && uppercaseLetter == "L" && "abcdfghjklmnpqrstvwxz".Contains(st.StrippedText[1].ToString()))
uppercaseLetter = "I";
if (st.StrippedText.StartsWith("lo ") && _threeLetterIsoLanguageName == "ita")
uppercaseLetter = "I";
st.StrippedText = st.StrippedText.Remove(0, 1).Insert(0, uppercaseLetter);
input = st.Pre + st.StrippedText + st.Post;
}