mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-26 15:02:35 +02:00
OCR italic fix again - thx Zoltan :)
This commit is contained in:
parent
d12b632fb7
commit
0d45a60a75
@ -75,6 +75,41 @@ namespace Test.Logic.Ocr
|
||||
Assert.AreEqual("He said: <i>''Go now!''</i>", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestColonInItalic()
|
||||
{
|
||||
var matches = new List<VobSubOcr.CompareMatch>
|
||||
{
|
||||
new VobSubOcr.CompareMatch("[", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("O", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("v", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("e", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("r", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch(" ", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("c", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("o", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("m", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("s", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("]", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch(" ", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("H", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("o", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("w", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch(" ", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("a", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("r", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("e", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch(" ", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("y", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("o", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("u", true, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("?", true, 0, Guid.NewGuid().ToString()),
|
||||
};
|
||||
|
||||
var result = MatchesToItalicStringConverter.GetStringWithItalicTags(matches);
|
||||
Assert.AreEqual("<i>[Over coms] How are you?</i>", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestItalicAndColon()
|
||||
{
|
||||
|
@ -30,7 +30,8 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
var numberOfItalicLetters = GetNumberOfItalicLetters(lineMatches.Matches);
|
||||
if (numberOfItalicLetters == numberOfLetters || numberOfItalicLetters > 3 && numberOfLetters - numberOfItalicLetters < 2 && ItalicIsInsideWord(matches))
|
||||
{
|
||||
sb.AppendLine("<i>" + GetRawString(lineMatches.Matches) + "</i>");
|
||||
sb.Append("<i>" + GetRawString(lineMatches.Matches) + "</i>");
|
||||
sb.Append(lineMatches.Separator);
|
||||
}
|
||||
else if (numberOfItalicLetters == 0 || numberOfLetters > 2 && numberOfItalicLetters < 2)
|
||||
{
|
||||
@ -49,6 +50,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
text = text.Replace(" ", " ");
|
||||
text = text.Replace("<i> ", " <i>");
|
||||
text = text.Replace(" </i>", "</i> ");
|
||||
text = text.Replace("</i> <i>", " ");
|
||||
text = text.Replace(" ", " ");
|
||||
|
||||
return text.Trim();
|
||||
|
Loading…
Reference in New Issue
Block a user