From 0fc3ffd36e9296d9a76074b0f938108f70bebb34 Mon Sep 17 00:00:00 2001 From: niksedk Date: Fri, 1 Nov 2013 17:56:02 +0000 Subject: [PATCH] Minor ocr fix regarding ! vs l git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2161 99eadd0c-20b8-1223-b5c4-2a2b2df33de2 --- src/Forms/VobSubOcr.cs | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/Forms/VobSubOcr.cs b/src/Forms/VobSubOcr.cs index 422ed8325..fc37757e5 100644 --- a/src/Forms/VobSubOcr.cs +++ b/src/Forms/VobSubOcr.cs @@ -5008,9 +5008,49 @@ namespace Nikse.SubtitleEdit.Forms if (line.EndsWith("!") && !unItalicText.EndsWith("!") && !unItalicText.EndsWith("!")) { if (unItalicText.EndsWith("!'")) + { unItalicText = unItalicText.TrimEnd('\''); + } else - unItalicText += "!"; + { + if (unItalicText.EndsWith("l") && _ocrFixEngine != null) + { + string w = unItalicText.Substring(0, unItalicText.Length - 4); + int wIdx = w.Length - 1; + while (wIdx >= 0 && !(" .,!?<>:;'-$@£()[]<>/\"".Contains(w[wIdx].ToString()))) + { + wIdx--; + } + if (wIdx + 1 < w.Length && unItalicText.Length > 5) + { + w = w.Substring(wIdx + 1); + if (!_ocrFixEngine.DoSpell(w)) + unItalicText = unItalicText.Remove(unItalicText.Length - 5, 1); + } + unItalicText = unItalicText.Insert(unItalicText.Length - 4, "!"); + } + else if (unItalicText.EndsWith("l") && _ocrFixEngine != null) + { + string w = unItalicText; + int wIdx = w.Length - 1; + while (wIdx >= 0 && !(" .,!?<>:;'-$@£()[]<>/\"".Contains(w[wIdx].ToString()))) + { + wIdx--; + } + if (wIdx + 1 < w.Length && unItalicText.Length > 5) + { + w = w.Substring(wIdx + 1); + if (!_ocrFixEngine.DoSpell(w)) + unItalicText = unItalicText.Remove(unItalicText.Length - 1, 1); + } + unItalicText += "!"; + } + else + { + unItalicText += "!"; + } + + } } if (line.EndsWith("?") && !unItalicText.EndsWith("?") && !unItalicText.EndsWith("?")) {