One more italic ocr fix - thx Zoltan :)

This commit is contained in:
Nikolaj Olsson 2024-10-31 05:57:41 +01:00
parent 40262121b0
commit 4ccce2018e
3 changed files with 30 additions and 3 deletions

View File

@ -3,8 +3,8 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageVersion Include="MSTest" Version="3.6.0" /> <PackageVersion Include="MSTest" Version="3.6.1" />
<PackageVersion Include="System.Drawing.Common" Version="8.0.8" /> <PackageVersion Include="System.Drawing.Common" Version="8.0.10" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" /> <PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="UTF.Unknown" Version="2.5.1" /> <PackageVersion Include="UTF.Unknown" Version="2.5.1" />
<PackageVersion Include="zlib.net-mutliplatform" Version="1.0.8" /> <PackageVersion Include="zlib.net-mutliplatform" Version="1.0.8" />

View File

@ -284,6 +284,29 @@ namespace Test.Logic.Ocr
Assert.AreEqual("Joe:\r\n<i>Godbye!</i>", result); Assert.AreEqual("Joe:\r\n<i>Godbye!</i>", result);
} }
public void TestWordInItalicSecondLineAndBrackets()
{
var matches = new List<VobSubOcr.CompareMatch>
{
new VobSubOcr.CompareMatch("[J", false, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("o", false, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("e", false, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("]:", false, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("\r", false, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("\n", false, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("G", true, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("o", true, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("d", true, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("b", true, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("y", true, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("e", true, 0, Guid.NewGuid().ToString()),
new VobSubOcr.CompareMatch("!", true, 0, Guid.NewGuid().ToString()),
};
string result = MatchesToItalicStringConverter.GetStringWithItalicTags(matches);
Assert.AreEqual("[Joe]:\r\n<i>Godbye!</i>", result);
}
[TestMethod] [TestMethod]
public void TestPartInItalic() public void TestPartInItalic()
{ {

View File

@ -220,7 +220,11 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
if (line.Count > 0) if (line.Count > 0)
{ {
line.Add(t); line.Add(t);
if (index < matches.Count - 1 && matches[index + 1].Text == Environment.NewLine) if (index < matches.Count - 1 && ":)]".Contains(matches[index + 1].ToString()))
{
continue;
}
else if (index < matches.Count - 1 && matches[index + 1].Text == Environment.NewLine)
{ {
result.Add(new SplitItem { Matches = line, Separator = Environment.NewLine }); result.Add(new SplitItem { Matches = line, Separator = Environment.NewLine });
skipNext = true; skipNext = true;