mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Fix #8184 - thx Codling/ivandrofly :)
This commit is contained in:
parent
9dad06922b
commit
dc37f04338
@ -563,6 +563,28 @@ namespace Test.FixCommonErrors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void FixCommonOcrErrorsFrenchHardCodedRuleNoChange2()
|
||||||
|
{
|
||||||
|
using (var target = GetFixCommonErrorsLib())
|
||||||
|
{
|
||||||
|
InitializeFixCommonErrorsLine(target, "Je connaîtrai la peur." + Environment.NewLine + "La peur tue l'esprit.");
|
||||||
|
target.FixOcrErrorsViaReplaceList("fra");
|
||||||
|
Assert.AreEqual("Je connaîtrai la peur." + Environment.NewLine + "La peur tue l'esprit.", target.Subtitle.Paragraphs[0].Text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void FixCommonOcrErrorsFrenchHardCodedRuleNoChange3()
|
||||||
|
{
|
||||||
|
using (var target = GetFixCommonErrorsLib())
|
||||||
|
{
|
||||||
|
InitializeFixCommonErrorsLine(target, "Je connaîtrai la peur." + Environment.NewLine + "La peur tue l'Esprit tue et.");
|
||||||
|
target.FixOcrErrorsViaReplaceList("fra");
|
||||||
|
Assert.AreEqual("Je connaîtrai la peur." + Environment.NewLine + "La peur tue l'Esprit tue et.", target.Subtitle.Paragraphs[0].Text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Fix OCR errors
|
#endregion Fix OCR errors
|
||||||
|
|
||||||
#region Fix missing spaces
|
#region Fix missing spaces
|
||||||
|
@ -666,7 +666,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
|||||||
private static bool IsToKeepCasing(string sentence)
|
private static bool IsToKeepCasing(string sentence)
|
||||||
{
|
{
|
||||||
// related to https://github.com/SubtitleEdit/subtitleedit/issues/8052
|
// related to https://github.com/SubtitleEdit/subtitleedit/issues/8052
|
||||||
if (sentence.Length > 2)
|
if (sentence.Length > 2 && IsCurrentWordUpperCase(sentence))
|
||||||
{
|
{
|
||||||
// do not change 'L' to lowercase in text like "L'ASSASSIN"
|
// do not change 'L' to lowercase in text like "L'ASSASSIN"
|
||||||
return char.IsUpper(sentence[2]) && (sentence[1] == '\'' || sentence[1] == '’');
|
return char.IsUpper(sentence[2]) && (sentence[1] == '\'' || sentence[1] == '’');
|
||||||
@ -675,6 +675,31 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsCurrentWordUpperCase(string sentence)
|
||||||
|
{
|
||||||
|
var maxMinusOne = sentence.Length - 1;
|
||||||
|
for (var i = 2; i <= maxMinusOne; i++)
|
||||||
|
{
|
||||||
|
var ch = sentence[i];
|
||||||
|
if (!char.IsLetter(ch))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!char.IsUpper(ch))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == maxMinusOne)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static string FixFrenchLApostrophe(string input, string affix, string prevLine)
|
public static string FixFrenchLApostrophe(string input, string affix, string prevLine)
|
||||||
{
|
{
|
||||||
var text = input;
|
var text = input;
|
||||||
|
Loading…
Reference in New Issue
Block a user