Working on moving logic from FixCommonErrors form to libse

This commit is contained in:
niksedk 2015-09-19 09:28:36 +02:00
parent 8a77a7caed
commit a39c3b9b5f
39 changed files with 2772 additions and 2567 deletions

View File

@ -0,0 +1,174 @@
using System;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class AddMissingQuotes : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.AddMissingQuote;
int noOfFixes = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
if (Utilities.CountTagInText(p.Text, '"') == 1)
{
Paragraph next = subtitle.GetParagraphOrDefault(i + 1);
if (next != null)
{
double betweenMilliseconds = next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds;
if (betweenMilliseconds > 1500)
next = null; // cannot be quote spanning several lines of more than 1.5 seconds between lines!
else if (next.Text.Replace("<i>", string.Empty).TrimStart().TrimStart('-').TrimStart().StartsWith('"') &&
next.Text.Replace("</i>", string.Empty).TrimEnd().EndsWith('"') &&
Utilities.CountTagInText(next.Text, '"') == 2)
next = null; // seems to have valid quotes, so no spanning
}
Paragraph prev = subtitle.GetParagraphOrDefault(i - 1);
if (prev != null)
{
double betweenMilliseconds = p.StartTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds;
if (betweenMilliseconds > 1500)
prev = null; // cannot be quote spanning several lines of more than 1.5 seconds between lines!
else if (prev.Text.Replace("<i>", string.Empty).TrimStart().TrimStart('-').TrimStart().StartsWith('"') &&
prev.Text.Replace("</i>", string.Empty).TrimEnd().EndsWith('"') &&
Utilities.CountTagInText(prev.Text, '"') == 2)
prev = null; // seems to have valid quotes, so no spanning
}
string oldText = p.Text;
var lines = HtmlUtil.RemoveHtmlTags(p.Text).SplitToLines();
if (lines.Length == 2 && lines[0].TrimStart().StartsWith('-') && lines[1].TrimStart().StartsWith('-'))
{ // dialog
lines = p.Text.SplitToLines();
string line = lines[0].Trim();
if (line.Length > 5 && line.TrimStart().StartsWith("- \"", StringComparison.Ordinal) && (line.EndsWith('.') || line.EndsWith('!') || line.EndsWith('?')))
{
p.Text = p.Text.Trim().Replace(" " + Environment.NewLine, Environment.NewLine);
p.Text = p.Text.Replace(Environment.NewLine, "\"" + Environment.NewLine);
}
else if (line.Length > 5 && line.EndsWith('"') && line.Contains("- ") && line.IndexOf("- ", StringComparison.Ordinal) < 4)
{
p.Text = p.Text.Insert(line.IndexOf("- ", StringComparison.Ordinal) + 2, "\"");
}
else if (line.Contains('"') && line.IndexOf('"') > 2 && line.IndexOf('"') < line.Length - 3)
{
int index = line.IndexOf('"');
if (line[index - 1] == ' ')
{
p.Text = p.Text.Trim().Replace(" " + Environment.NewLine, Environment.NewLine);
p.Text = p.Text.Replace(Environment.NewLine, "\"" + Environment.NewLine);
}
else if (line[index + 1] == ' ')
{
if (line.Length > 5 && line.Contains("- ") && line.IndexOf("- ", StringComparison.Ordinal) < 4)
p.Text = p.Text.Insert(line.IndexOf("- ", StringComparison.Ordinal) + 2, "\"");
}
}
else if (lines[1].Contains('"'))
{
line = lines[1].Trim();
if (line.Length > 5 && line.TrimStart().StartsWith("- \"", StringComparison.Ordinal) && (line.EndsWith('.') || line.EndsWith('!') || line.EndsWith('?')))
{
p.Text = p.Text.Trim() + "\"";
}
else if (line.Length > 5 && line.EndsWith('"') && p.Text.Contains(Environment.NewLine + "- "))
{
p.Text = p.Text.Insert(p.Text.IndexOf(Environment.NewLine + "- ", StringComparison.Ordinal) + Environment.NewLine.Length + 2, "\"");
}
else if (line.Contains('"') && line.IndexOf('"') > 2 && line.IndexOf('"') < line.Length - 3)
{
int index = line.IndexOf('"');
if (line[index - 1] == ' ')
{
p.Text = p.Text.Trim() + "\"";
}
else if (line[index + 1] == ' ')
{
if (line.Length > 5 && p.Text.Contains(Environment.NewLine + "- "))
p.Text = p.Text.Insert(p.Text.IndexOf(Environment.NewLine + "- ", StringComparison.Ordinal) + Environment.NewLine.Length + 2, "\"");
}
}
}
}
else
{ // not dialog
if (p.Text.StartsWith('"'))
{
if (next == null || !next.Text.Contains('"'))
p.Text += "\"";
}
else if (p.Text.StartsWith("<i>\"", StringComparison.Ordinal) && p.Text.EndsWith("</i>", StringComparison.Ordinal) && Utilities.CountTagInText(p.Text, "</i>") == 1)
{
if (next == null || !next.Text.Contains('"'))
p.Text = p.Text.Replace("</i>", "\"</i>");
}
else if (p.Text.EndsWith('"'))
{
if (prev == null || !prev.Text.Contains('"'))
p.Text = "\"" + p.Text;
}
else if (p.Text.Contains(Environment.NewLine + "\"") && Utilities.GetNumberOfLines(p.Text) == 2)
{
if (next == null || !next.Text.Contains('"'))
p.Text = p.Text + "\"";
}
else if ((p.Text.Contains(Environment.NewLine + "\"") || p.Text.Contains(Environment.NewLine + "-\"") || p.Text.Contains(Environment.NewLine + "- \"")) &&
Utilities.GetNumberOfLines(p.Text) == 2 && p.Text.Length > 3)
{
if (next == null || !next.Text.Contains('"'))
{
if (p.Text.StartsWith("<i>", StringComparison.Ordinal) && p.Text.EndsWith("</i>", StringComparison.Ordinal) && Utilities.CountTagInText(p.Text, "</i>") == 1)
p.Text = p.Text.Replace("</i>", "\"</i>");
else
p.Text = p.Text + "\"";
}
}
else if (p.Text.StartsWith("<i>", StringComparison.Ordinal) && p.Text.EndsWith("</i>", StringComparison.Ordinal) && Utilities.CountTagInText(p.Text, "<i>") == 1)
{
if (prev == null || !prev.Text.Contains('"'))
p.Text = p.Text.Replace("<i>", "<i>\"");
}
else if (p.Text.Contains('"'))
{
string text = p.Text;
int indexOfQuote = p.Text.IndexOf('"');
if (text.Contains('"') && indexOfQuote > 2 && indexOfQuote < text.Length - 3)
{
int index = text.IndexOf('"');
if (text[index - 1] == ' ')
{
if (p.Text.EndsWith(','))
p.Text = p.Text.Insert(p.Text.Length - 1, "\"").Trim();
else
p.Text = p.Text.Trim() + "\"";
}
else if (text[index + 1] == ' ')
p.Text = "\"" + p.Text;
}
}
}
if (oldText != p.Text)
{
if (callbacks.AllowFix(p, fixAction))
{
noOfFixes++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
else
{
p.Text = oldText;
}
}
}
}
callbacks.UpdateFixStatus(noOfFixes, fixAction, language.XMissingQuotesAdded);
}
}
}

View File

@ -1,12 +1,12 @@
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using System.Collections.Generic;
using System.Text;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class EmptyFixCallback : IFixCallbacks
{
private string _language = "en";
public bool AllowFix(Paragraph p, string action)
{
return true;
@ -24,15 +24,15 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
}
public void AddToTotalFixes(int count)
public void UpdateFixStatus(int fixes, string message, string xMessage)
{
}
public void AddtoTotalErrors(int count)
public void AddToTotalErrors(int count)
{
}
public void AddtoDeleteIndices(int index)
public void AddToDeleteIndices(int index)
{
}
@ -41,10 +41,29 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
get { return new SubRip(); }
}
private string _language = "en";
public string Language
{
get { return _language; }
set { _language = value; }
}
public bool IsName(string candidate)
{
return false;
}
private Encoding _encoding = Encoding.UTF8;
public Encoding Encoding
{
get { return _encoding; }
set { _encoding = value; }
}
public List<string> GetAbbreviations()
{
return new List<string>();
}
}
}

View File

@ -0,0 +1,24 @@
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class Fix3PlusLines : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.Fix3PlusLine;
int iFixes = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
if (Utilities.GetNumberOfLines(p.Text) > 2 && callbacks.AllowFix(p, fixAction))
{
string oldText = p.Text;
p.Text = Utilities.AutoBreakLine(p.Text);
iFixes++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
callbacks.UpdateFixStatus(iFixes, language.Fix3PlusLines, language.X3PlusLinesFixed);
}
}
}

View File

@ -0,0 +1,95 @@
using System;
using System.Text.RegularExpressions;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixAloneLowercaseIToUppercaseI : IFixCommonError
{
public static readonly Regex FixAloneLowercaseIToUppercaseIre = new Regex(@"\bi\b", RegexOptions.Compiled);
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixLowercaseIToUppercaseI;
int iFixes = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
string oldText = p.Text;
string s = p.Text;
if (s.Contains('i'))
{
s = FixAloneLowercaseIToUppercaseLine(FixAloneLowercaseIToUppercaseIre, oldText, s, 'i');
if (s != oldText && callbacks.AllowFix(p, fixAction))
{
p.Text = s;
iFixes++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
}
callbacks.UpdateFixStatus(iFixes, language.FixLowercaseIToUppercaseI, language.XIsChangedToUppercase);
}
public static string FixAloneLowercaseIToUppercaseLine(Regex re, string oldText, string s, char target)
{
//html tags
if (s.Contains(">" + target + "</"))
s = s.Replace(">" + target + "</", ">I</");
if (s.Contains(">" + target + " "))
s = s.Replace(">" + target + " ", ">I ");
if (s.Contains(">" + target + "\u200B" + Environment.NewLine)) // Zero Width Space
s = s.Replace(">" + target + "\u200B" + Environment.NewLine, ">I" + Environment.NewLine);
if (s.Contains(">" + target + "\uFEFF" + Environment.NewLine)) // Zero Width No-Break Space
s = s.Replace(">" + target + "\uFEFF" + Environment.NewLine, ">I" + Environment.NewLine);
// reg-ex
Match match = re.Match(s);
while (match.Success)
{
if (s[match.Index] == target && !s.Substring(match.Index).StartsWith("i.e.", StringComparison.Ordinal))
{
var prev = '\0';
var next = '\0';
if (match.Index > 0)
prev = s[match.Index - 1];
if (match.Index + 1 < s.Length)
next = s[match.Index + 1];
string wholePrev = string.Empty;
if (match.Index > 1)
wholePrev = s.Substring(0, match.Index - 1);
if (prev != '>' && next != '>' && next != '}' && !wholePrev.TrimEnd().EndsWith("...", StringComparison.Ordinal))
{
bool fix = true;
if (prev == '.' || prev == '\'')
fix = false;
if (prev == ' ' && next == '.')
fix = false;
if (prev == '-' && match.Index > 2)
fix = false;
if (fix && next == '-' && match.Index < s.Length - 5 && s[match.Index + 2] == 'l' && !(Environment.NewLine + @" <>!.?:;,").Contains(s[match.Index + 3]))
fix = false;
if (fix)
{
string temp = s.Substring(0, match.Index) + "I";
if (match.Index + 1 < oldText.Length)
temp += s.Substring(match.Index + 1);
s = temp;
}
}
}
match = match.NextMatch();
}
return s;
}
}
}

View File

@ -0,0 +1,688 @@
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixDanishLetterI : IFixCommonError
{
private static Regex MyRegEx(string inputRegex)
{
return new Regex(inputRegex.Replace(" ", "[ \r\n]+"), RegexOptions.Compiled);
}
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
const string fixAction = "Fix Danish letter 'i'";
int fixCount = 0;
var littleIRegex = new Regex(@"\bi\b", RegexOptions.Compiled);
var iList = new List<Regex>
{ // not a complete list, more phrases will come
MyRegEx(@", i ved nok\b"),
MyRegEx(@", i ved, "),
MyRegEx(@", i ved."),
MyRegEx(@", i ikke blev\b"),
MyRegEx(@"\b i føler at\b"),
MyRegEx(@"\badvarede i os\b"),
MyRegEx(@"\badvarede i dem\b"),
MyRegEx(@"\bat i aldrig\b"),
MyRegEx(@"\bat i alle bliver\b"),
MyRegEx(@"\bat i alle er\b"),
MyRegEx(@"\bat i alle forventer\b"),
MyRegEx(@"\bat i alle gør\b"),
MyRegEx(@"\bat i alle har\b"),
MyRegEx(@"\bat i alle ved\b"),
MyRegEx(@"\bat i alle vil\b"),
MyRegEx(@"\bat i bare\b"),
MyRegEx(@"\bat i bager\b"),
MyRegEx(@"\bat i bruger\b"),
MyRegEx(@"\bat i dræber\b"),
MyRegEx(@"\bat i dræbte\b"),
MyRegEx(@"\bat i fandt\b"),
MyRegEx(@"\bat i fik\b"),
MyRegEx(@"\bat i finder\b"),
MyRegEx(@"\bat i forstår\b"),
MyRegEx(@"\bat i får\b"),
MyRegEx(@"\b[Aa]t i hver især\b"),
MyRegEx(@"\bAt i ikke\b"),
MyRegEx(@"\bat i ikke\b"),
MyRegEx(@"\bat i kom\b"),
MyRegEx(@"\bat i kommer\b"),
MyRegEx(@"\bat i næsten er\b"),
MyRegEx(@"\bat i næsten fik\b"),
MyRegEx(@"\bat i næsten har\b"),
MyRegEx(@"\bat i næsten skulle\b"),
MyRegEx(@"\bat i næsten var\b"),
MyRegEx(@"\bat i også får\b"),
MyRegEx(@"\bat i også gør\b"),
MyRegEx(@"\bat i også mener\b"),
MyRegEx(@"\bat i også siger\b"),
MyRegEx(@"\bat i også tror\b"),
MyRegEx(@"\bat i rev\b"),
MyRegEx(@"\bat i river\b"),
MyRegEx(@"\bat i samarbejder\b"),
MyRegEx(@"\bat i snakkede\b"),
MyRegEx(@"\bat i scorer\b"),
MyRegEx(@"\bat i siger\b"),
MyRegEx(@"\bat i skal\b"),
MyRegEx(@"\bat i skulle\b"),
MyRegEx(@"\bat i to ikke\b"),
MyRegEx(@"\bat i to siger\b"),
MyRegEx(@"\bat i to har\b"),
MyRegEx(@"\bat i to er\b"),
MyRegEx(@"\bat i to bager\b"),
MyRegEx(@"\bat i to skal\b"),
MyRegEx(@"\bat i to gør\b"),
MyRegEx(@"\bat i to får\b"),
MyRegEx(@"\bat i udnyttede\b"),
MyRegEx(@"\bat i udnytter\b"),
MyRegEx(@"\bat i vil\b"),
MyRegEx(@"\bat i ville\b"),
MyRegEx(@"\bBehandler i mig\b"),
MyRegEx(@"\bbehandler i mig\b"),
MyRegEx(@"\bbliver i rige\b"),
MyRegEx(@"\bbliver i ikke\b"),
MyRegEx(@"\bbliver i indkvarteret\b"),
MyRegEx(@"\bbliver i indlogeret\b"),
MyRegEx(@"\bburde i gøre\b"),
MyRegEx(@"\bburde i ikke\b"),
MyRegEx(@"\bburde i købe\b"),
MyRegEx(@"\bburde i løbe\b"),
MyRegEx(@"\bburde i se\b"),
MyRegEx(@"\bburde i sige\b"),
MyRegEx(@"\bburde i tage\b"),
MyRegEx(@"\bDa i ankom\b"),
MyRegEx(@"\bda i ankom\b"),
MyRegEx(@"\bda i forlod\b"),
MyRegEx(@"\bDa i forlod\b"),
MyRegEx(@"\bda i fik\b"),
MyRegEx(@"\bDa i fik\b"),
MyRegEx(@"\bDa i gik\b"),
MyRegEx(@"\bda i gik\b"),
MyRegEx(@"\bda i kom\b"),
MyRegEx(@"\bDa i kom\b"),
MyRegEx(@"\bda i så "),
MyRegEx(@"\bDa i så "),
MyRegEx(@"\bdet får i\b"),
MyRegEx(@"\bDet får i\b"),
MyRegEx(@"\bDet har i\b"),
MyRegEx(@"\bdet har i\b"),
MyRegEx(@"\bDet må i "),
MyRegEx(@"\bdet må i "),
MyRegEx(@"\b[Dd]et Det kan i sgu"),
MyRegEx(@"\bend i aner\b"),
MyRegEx(@"\bend i tror\b"),
MyRegEx(@"\bend i ved\b"),
MyRegEx(@"\b, er i alle\b"),
MyRegEx(@"\bellers får i "),
MyRegEx(@"\bEr i alle\b"),
MyRegEx(@"\ber i allerede\b"),
MyRegEx(@"\bEr i allerede\b"),
MyRegEx(@"\ber i allesammen\b"),
MyRegEx(@"\bEr i allesammen\b"),
MyRegEx(@"\ber i der\b"),
MyRegEx(@"\bEr i der\b"),
MyRegEx(@"\bEr i fra\b"),
MyRegEx(@"\bEr i gennem\b"),
MyRegEx(@"\ber i gennem\b"),
MyRegEx(@"\ber i glade\b"),
MyRegEx(@"\bEr i glade\b"),
MyRegEx(@"\bEr i gået\b"),
MyRegEx(@"\ber i gået\b"),
MyRegEx(@"\ber i her\b"),
MyRegEx(@"\bEr i her\b"),
MyRegEx(@"\ber i imod\b"),
MyRegEx(@"\bEr i imod\b"),
MyRegEx(@"\ber i klar\b"),
MyRegEx(@"\bEr i klar\b"),
MyRegEx(@"\bEr i mætte\b"),
MyRegEx(@"\ber i mætte\b"),
MyRegEx(@"\bEr i med\b"),
MyRegEx(@"\ber i med\b"),
MyRegEx(@"\ber i mod\b"),
MyRegEx(@"\bEr i mod\b"),
MyRegEx(@"\ber i okay\b"),
MyRegEx(@"\bEr i okay\b"),
MyRegEx(@"\ber i på\b"),
MyRegEx(@"\bEr i på\b"),
MyRegEx(@"\bEr i parate\b"),
MyRegEx(@"\ber i parate\b"),
MyRegEx(@"\ber i sikker\b"),
MyRegEx(@"\bEr i sikker\b"),
MyRegEx(@"\bEr i sikre\b"),
MyRegEx(@"\ber i sikre\b"),
MyRegEx(@"\ber i skøre\b"),
MyRegEx(@"\bEr i skøre\b"),
MyRegEx(@"\ber i stadig\b"),
MyRegEx(@"\bEr i stadig\b"),
MyRegEx(@"\bEr i sultne\b"),
MyRegEx(@"\ber i sultne\b"),
MyRegEx(@"\bEr i tilfredse\b"),
MyRegEx(@"\ber i tilfredse\b"),
MyRegEx(@"\bEr i to\b"),
MyRegEx(@"\ber i ved at\b"),
MyRegEx(@"\ber i virkelig\b"),
MyRegEx(@"\bEr i virkelig\b"),
MyRegEx(@"\bEr i vågne\b"),
MyRegEx(@"\ber i vågne\b"),
MyRegEx(@"\bfanden vil i?"),
MyRegEx(@"\bfor ser i\b"),
MyRegEx(@"\bFor ser i\b"),
MyRegEx(@"\bFordi i ventede\b"),
MyRegEx(@"\bfordi i ventede\b"),
MyRegEx(@"\bFordi i deltog\b"),
MyRegEx(@"\bfordi i deltog\b"),
MyRegEx(@"\bforhandler i stadig\b"),
MyRegEx(@"\bForhandler i stadig\b"),
MyRegEx(@"\bforstår i\b"),
MyRegEx(@"\bForstår i\b"),
MyRegEx(@"\bFør i får\b"),
MyRegEx(@"\bfør i får\b"),
MyRegEx(@"\bFør i kommer\b"),
MyRegEx(@"\bfør i kommer\b"),
MyRegEx(@"\bFør i tager\b"),
MyRegEx(@"\bfør i tager\b"),
MyRegEx(@"\bfår i alle\b"),
MyRegEx(@"\bfår i fratrukket\b"),
MyRegEx(@"\bfår i ikke\b"),
MyRegEx(@"\bfår i klø\b"),
MyRegEx(@"\bfår i point\b"),
MyRegEx(@"\bgider i at\b"),
MyRegEx(@"\bGider i at\b"),
MyRegEx(@"\bGider i ikke\b"),
MyRegEx(@"\bgider i ikke\b"),
MyRegEx(@"\bgider i lige\b"),
MyRegEx(@"\bGider i lige\b"),
MyRegEx(@"\b[Gg]ik i lige\b"),
MyRegEx(@"\b[Gg]ik i hjem\b"),
MyRegEx(@"\b[Gg]ik i over\b"),
MyRegEx(@"\b[Gg]ik i forbi\b"),
MyRegEx(@"\b[Gg]ik i ind\b"),
MyRegEx(@"\b[Gg]ik i uden\b"),
MyRegEx(@"\bGjorde i det\b"),
MyRegEx(@"\bGjorde i det\b"),
MyRegEx(@"\bgjorde i ikke\b"),
MyRegEx(@"\bGider i godt\b"),
MyRegEx(@"\bgider i godt\b"),
MyRegEx(@"\bGider i ikke\b"),
MyRegEx(@"\bgider i ikke\b"),
MyRegEx(@"\b[Gg]iver i mig\b"),
MyRegEx(@"\bglor i på\b"),
MyRegEx(@"\bGlor i på\b"),
MyRegEx(@"\b[Gg]lor i allesammen på\b"),
MyRegEx(@"\b[Gg]lor i alle på\b"),
MyRegEx(@"\bGår i ind\b"),
MyRegEx(@"\bgår i ind\b"),
MyRegEx(@"\b[Gg]å i bare\b"),
MyRegEx(@"\bHørte i det\b"),
MyRegEx(@"\bhørte i det\b"),
MyRegEx(@"\bHar i \b"),
MyRegEx(@"\bhar i ødelagt\b"),
MyRegEx(@"\bhar i fået\b"),
MyRegEx(@"\bHar i fået\b"),
MyRegEx(@"\bHar i det\b"),
MyRegEx(@"\bhar i det\b"),
MyRegEx(@"\bhar i gjort\b"),
MyRegEx(@"\bhar i ikke\b"),
MyRegEx(@"\bHar i nogen\b"),
MyRegEx(@"\bhar i nogen\b"),
MyRegEx(@"\bHar i nok\b"),
MyRegEx(@"\bhar i nok\b"),
MyRegEx(@"\bhar i ordnet\b"),
MyRegEx(@"\bHar i ordnet\b"),
MyRegEx(@"\bhar i spist\b"),
MyRegEx(@"\bHar i spist\b"),
MyRegEx(@"\bhar i tænkt\b"),
MyRegEx(@"\bhar i tabt\b"),
MyRegEx(@"\bhelvede vil i?"),
MyRegEx(@"\bHer har i\b"),
MyRegEx(@"\bher har i\b"),
MyRegEx(@"\b[Hh]older i fast\b"),
MyRegEx(@"\b[Hh]older i godt fast\b"),
MyRegEx(@"\bHvad fanden har i\b"),
MyRegEx(@"\bhvad fanden har i\b"),
MyRegEx(@"\bHvad fanden tror i\b"),
MyRegEx(@"\bhvad fanden tror i\b"),
MyRegEx(@"\bhvad fanden vil i\b"),
MyRegEx(@"\bHvad fanden vil i\b"),
MyRegEx(@"\bHvad gør i\b"),
MyRegEx(@"\bhvad gør i\b"),
MyRegEx(@"\bhvad har i\b"),
MyRegEx(@"\bHvad har i\b"),
MyRegEx(@"\bHvad i ikke\b"),
MyRegEx(@"\bhvad i ikke\b"),
MyRegEx(@"\b[Hh]vad laver i\b"),
MyRegEx(@"\b[Hh]vad lavede i\b"),
MyRegEx(@"\b[Hh]vad mener i\b"),
MyRegEx(@"\b[Hh]vad siger i\b"),
MyRegEx(@"\b[Hh]vad skal i\b"),
MyRegEx(@"\b[Hh]vad snakker i\b"),
MyRegEx(@"\b[Hh]vad sløver i\b"),
MyRegEx(@"\b[Hh]vad synes i\b"),
MyRegEx(@"\b[Hh]vad vil i\b"),
MyRegEx(@"\b[Hh]vem er i\b"),
MyRegEx(@"\b[Hh]vem fanden tror i\b"),
MyRegEx(@"\b[Hh]vem tror i\b"),
MyRegEx(@"\b[Hh]vilken slags mennesker er i?"),
MyRegEx(@"\b[Hh]vilken slags folk er i?"),
MyRegEx(@"\b[Hh]vis i altså\b"),
MyRegEx(@"\b[Hh]vis i bare\b"),
MyRegEx(@"\b[Hh]vis i forstår\b"),
MyRegEx(@"\b[Hh]vis i får\b"),
MyRegEx(@"\b[Hh]vis i går\b"),
MyRegEx(@"\b[Hh]vis i ikke\b"),
MyRegEx(@"\b[Hh]vis i lovede\b"),
MyRegEx(@"\b[Hh]vis i lover\b"),
MyRegEx(@"\b[Hh]vis i overholder\b"),
MyRegEx(@"\b[Hh]vis i overtræder\b"),
MyRegEx(@"\b[Hh]vis i slipper\b"),
MyRegEx(@"\b[Hh]vis i taber\b"),
MyRegEx(@"\b[Hh]vis i vandt\b"),
MyRegEx(@"\b[Hh]vis i vinder\b"),
MyRegEx(@"\b[Hh]vor er i\b"),
MyRegEx(@"\b[Hh]vor får i\b"),
MyRegEx(@"\b[Hh]vor gamle er i\b"),
MyRegEx(@"\b[Hh]vor i begyndte\b"),
MyRegEx(@"\b[Hh]vor i startede\b"),
MyRegEx(@"\b[Hh]vor skal i\b"),
MyRegEx(@"\b[Hh]vor var i\b"),
MyRegEx(@"\b[Hh]vordan har i\b"),
MyRegEx(@"\b[Hh]vordan hørte i\b"),
MyRegEx(@"\b[Hh]vordan i når\b"),
MyRegEx(@"\b[Hh]vordan i nåede\b"),
MyRegEx(@"\b[Hh]vordan kunne i\b"),
MyRegEx(@"\b[Hh]vorfor afleverer i det\b"),
MyRegEx(@"\b[Hh]vorfor gør i "),
MyRegEx(@"\b[Hh]vorfor gjorde i "),
MyRegEx(@"\b[Hh]vorfor græder i "),
MyRegEx(@"\b[Hh]vorfor har i "),
MyRegEx(@"\b[Hh]vorfor kom i "),
MyRegEx(@"\b[Hh]vorfor kommer i "),
MyRegEx(@"\b[Hh]vorfor løb i "),
MyRegEx(@"\b[Hh]vorfor lover i "),
MyRegEx(@"\b[Hh]vorfor lovede i "),
MyRegEx(@"\b[Hh]vorfor skal i\b"),
MyRegEx(@"\b[Hh]vorfor skulle i\b"),
MyRegEx(@"\b[Hh]vorfor sagde i\b"),
MyRegEx(@"\b[Hh]vorfor synes i\b"),
MyRegEx(@"\b[Hh]vornår gør i "),
MyRegEx(@"\bHvornår kom i\b"),
MyRegEx(@"\b[Hh]vornår ville i "),
MyRegEx(@"\b[Hh]vornår giver i "),
MyRegEx(@"\b[Hh]vornår gav i "),
MyRegEx(@"\b[Hh]vornår rejser i\b"),
MyRegEx(@"\b[Hh]vornår rejste i\b"),
MyRegEx(@"\b[Hh]vornår skal i "),
MyRegEx(@"\b[Hh]vornår skulle i "),
MyRegEx(@"\b[Hh]ører i på\b"),
MyRegEx(@"\b[Hh]ørte i på\b"),
MyRegEx(@"\b[Hh]ører i,\b"),
MyRegEx(@"\b[Hh]ører i ikke\b"),
MyRegEx(@"\bi altid\b"),
MyRegEx(@"\bi ankomme\b"),
MyRegEx(@"\bi ankommer\b"),
MyRegEx(@"\bi bare kunne\b"),
MyRegEx(@"\bi bare havde\b"),
MyRegEx(@"\bi bare gjorde\b"),
MyRegEx(@"\bi begge er\b"),
MyRegEx(@"\bi begge gør\b"),
MyRegEx(@"\bi begge har\b"),
MyRegEx(@"\bi begge var\b"),
MyRegEx(@"\bi begge vil\b"),
MyRegEx(@"\bi behøver ikke gemme\b"),
MyRegEx(@"\bi behøver ikke prøve\b"),
MyRegEx(@"\bi behøver ikke skjule\b"),
MyRegEx(@"\bi behandlede\b"),
MyRegEx(@"\bi behandler\b"),
MyRegEx(@"\bi beskidte dyr\b"),
MyRegEx(@"\bi blev\b"),
MyRegEx(@"\bi blive\b"),
MyRegEx(@"\bi bliver\b"),
MyRegEx(@"\bi burde\b"),
MyRegEx(@"\bi er\b"),
MyRegEx(@"\bi fyrer af\b"),
MyRegEx(@"\bi gør\b"),
MyRegEx(@"\bi gav\b"),
MyRegEx(@"\bi gerne "),
MyRegEx(@"\bi giver\b"),
MyRegEx(@"\bi gjorde\b"),
MyRegEx(@"\bi hører\b"),
MyRegEx(@"\bi hørte\b"),
MyRegEx(@"\bi har\b"),
MyRegEx(@"\bi havde\b"),
MyRegEx(@"\bi igen bliver\b"),
MyRegEx(@"\bi igen burde\b"),
MyRegEx(@"\bi igen finder\b"),
MyRegEx(@"\bi igen gør\b"),
MyRegEx(@"\bi igen kommer\b"),
MyRegEx(@"\bi igen prøver\b"),
MyRegEx(@"\bi igen siger\b"),
MyRegEx(@"\bi igen skal\b"),
MyRegEx(@"\bi igen vil\b"),
MyRegEx(@"\bi ikke gerne\b"),
MyRegEx(@"\bi ikke kan\b"),
MyRegEx(@"\bi ikke kommer\b"),
MyRegEx(@"\bi ikke vil\b"),
MyRegEx(@"\bi kan\b"),
MyRegEx(@"\bi kender\b"),
MyRegEx(@"\bi kom\b"),
MyRegEx(@"\bi komme\b"),
MyRegEx(@"\bi kommer\b"),
MyRegEx(@"\bi kunne\b"),
MyRegEx(@"\bi morer jer\b"),
MyRegEx(@"\bi må gerne\b"),
MyRegEx(@"\bi må give\b"),
MyRegEx(@"\bi må da\b"),
MyRegEx(@"\bi nåede\b"),
MyRegEx(@"\bi når\b"),
MyRegEx(@"\bi prøve\b"),
MyRegEx(@"\bi prøvede\b"),
MyRegEx(@"\bi prøver\b"),
MyRegEx(@"\bi sagde\b"),
MyRegEx(@"\bi scorede\b"),
MyRegEx(@"\bi ser\b"),
MyRegEx(@"\bi set\b"),
MyRegEx(@"\bi siger\b"),
MyRegEx(@"\bi sikkert alle\b"),
MyRegEx(@"\bi sikkert ikke gør\b"),
MyRegEx(@"\bi sikkert ikke kan\b"),
MyRegEx(@"\bi sikkert ikke vil\b"),
MyRegEx(@"\bi skal\b"),
MyRegEx(@"\bi skulle\b"),
MyRegEx(@"\bi små stakler\b"),
MyRegEx(@"\bi stopper\b"),
MyRegEx(@"\bi synes\b"),
MyRegEx(@"\bi troede\b"),
MyRegEx(@"\bi tror\b"),
MyRegEx(@"\bi var\b"),
MyRegEx(@"\bi vel ikke\b"),
MyRegEx(@"\bi vil\b"),
MyRegEx(@"\bi ville\b"),
MyRegEx(@"\b[Kk]an i lugte\b"),
MyRegEx(@"\b[Kk]an i overleve\b"),
MyRegEx(@"\b[Kk]an i spise\b"),
MyRegEx(@"\b[Kk]an i se\b"),
MyRegEx(@"\b[Kk]an i smage\b"),
MyRegEx(@"\b[Kk]an i forstå\b"),
MyRegEx(@"\b[Kk]ørte i hele\b"),
MyRegEx(@"\b[Kk]ørte i ikke\b"),
MyRegEx(@"\b[Kk]an i godt\b"),
MyRegEx(@"\b[Kk]an i gøre\b"),
MyRegEx(@"\b[Kk]an i huske\b"),
MyRegEx(@"\b[Kk]an i ikke\b"),
MyRegEx(@"\b[Kk]an i lide\b"),
MyRegEx(@"\b[Kk]an i leve\b"),
MyRegEx(@"\b[Kk]an i love\b"),
MyRegEx(@"\b[Kk]an i måske\b"),
MyRegEx(@"\b[Kk]an i nok\b"),
MyRegEx(@"\b[Kk]an i se\b"),
MyRegEx(@"\b[Kk]an i sige\b"),
MyRegEx(@"\b[Kk]an i tilgive\b"),
MyRegEx(@"\b[Kk]an i tygge\b"),
MyRegEx(@"\b[Kk]an i to ikke\b"),
MyRegEx(@"\b[Kk]an i tro\b"),
MyRegEx(@"\bKender i "),
MyRegEx(@"\b[Kk]ender i hinanden\b"),
MyRegEx(@"\b[Kk]ender i to hinanden\b"),
MyRegEx(@"\bKendte i \b"),
MyRegEx(@"\b[Kk]endte i hinanden\b"),
MyRegEx(@"\b[Kk]iggede i på\b"),
MyRegEx(@"\b[Kk]igger i på\b"),
MyRegEx(@"\b[Kk]ommer i her\b"),
MyRegEx(@"\b[Kk]ommer i ofte\b"),
MyRegEx(@"\b[Kk]ommer i sammen\b"),
MyRegEx(@"\b[Kk]ommer i tit\b"),
MyRegEx(@"\b[Kk]unne i fortælle\b"),
MyRegEx(@"\b[Kk]unne i give\b"),
MyRegEx(@"\b[Kk]unne i gøre\b"),
MyRegEx(@"\b[Kk]unne i ikke\b"),
MyRegEx(@"\b[Kk]unne i lide\b"),
MyRegEx(@"\b[Kk]unne i mødes\b"),
MyRegEx(@"\b[Kk]unne i se\b"),
MyRegEx(@"\b[Ll]eder i efter\b"),
MyRegEx(@"\b[Ll]aver i ikke\b"),
MyRegEx(@"\blaver i her\b"),
MyRegEx(@"\b[Ll]igner i far\b"),
MyRegEx(@"\b[Ll]igner i hinanden\b"),
MyRegEx(@"\b[Ll]igner i mor\b"),
MyRegEx(@"\bLover i\b"),
MyRegEx(@"\b[Ll]ykkes i med\b"),
MyRegEx(@"\b[Ll]ykkedes i med\b"),
MyRegEx(@"\b[Ll]øb i hellere\b"),
MyRegEx(@"\b[Mm]ødte i "),
MyRegEx(@"\b[Mm]angler i en\b"),
MyRegEx(@"\b[Mm]en i gutter\b"),
MyRegEx(@"\b[Mm]en i drenge\b"),
MyRegEx(@"\b[Mm]en i fyre\b"),
MyRegEx(@"\b[Mm]en i står\b"),
MyRegEx(@"\b[Mm]ener i at\b"),
MyRegEx(@"\b[Mm]ener i det\b"),
MyRegEx(@"\b[Mm]ener i virkelig\b"),
MyRegEx(@"\b[Mm]ens i sov\b"),
MyRegEx(@"\b[Mm]ens i stadig\b"),
MyRegEx(@"\b[Mm]ens i lå\b"),
MyRegEx(@"\b[Mm]ister i point\b"),
MyRegEx(@"\b[Mm]orer i jer\b"),
MyRegEx(@"\b[Mm]å i alle"),
MyRegEx(@"\b[Mm]å i gerne"),
MyRegEx(@"\b[Mm]å i godt\b"),
MyRegEx(@"\b[Mm]å i vide\b"),
MyRegEx(@"\b[Mm]å i ikke"),
MyRegEx(@"\b[Nn]u løber i\b"),
MyRegEx(@"\b[Nn]u siger i\b"),
MyRegEx(@"\b[Nn]u skal i\b"),
MyRegEx(@"\b[Nn]år i\b"),
MyRegEx(@"\b[Oo]m i ikke\b"),
MyRegEx(@"\b[Oo]pgiver i\b"),
MyRegEx(@"\b[Oo]vergiver i jer\b"),
MyRegEx(@"\bpersoner i lukker\b"),
MyRegEx(@"\b[Pp]as på i ikke\b"),
MyRegEx(@"\b[Pp]as på i ikke\b"),
MyRegEx(@"\b[Pp]å i ikke\b"),
MyRegEx(@"\b[Pp]å at i ikke\b"),
MyRegEx(@"\b[Ss]agde i ikke\b"),
MyRegEx(@"\b[Ss]amlede i ham\b"),
MyRegEx(@"\bSer i\b"),
MyRegEx(@"\bSiger i\b"),
MyRegEx(@"\b[Ss]ikker på i ikke\b"),
MyRegEx(@"\b[Ss]ikre på i ikke\b"),
MyRegEx(@"\b[Ss]kal i alle\b"),
MyRegEx(@"\b[Ss]kal i allesammen\b"),
MyRegEx(@"\b[Ss]kal i begge dø\b"),
MyRegEx(@"\b[Ss]kal i bare\b"),
MyRegEx(@"\b[Ss]kal i dele\b"),
MyRegEx(@"\b[Ss]kal i dø\b"),
MyRegEx(@"\b[Ss]kal i fordele\b"),
MyRegEx(@"\b[Ss]kal i fordeles\b"),
MyRegEx(@"\b[Ss]kal i fortælle\b"),
MyRegEx(@"\b[Ss]kal i gøre\b"),
MyRegEx(@"\b[Ss]kal i have\b"),
MyRegEx(@"\b[Ss]kal i ikke\b"),
MyRegEx(@"\b[Ss]kal i klare\b"),
MyRegEx(@"\b[Ss]kal i klatre\b"),
MyRegEx(@"\b[Ss]kal i larme\b"),
MyRegEx(@"\b[Ss]kal i lave\b"),
MyRegEx(@"\b[Ss]kal i løfte\b"),
MyRegEx(@"\b[Ss]kal i med\b"),
MyRegEx(@"\b[Ss]kal i på\b"),
MyRegEx(@"\b[Ss]kal i til\b"),
MyRegEx(@"\b[Ss]kal i ud\b"),
MyRegEx(@"\b[Ss]lap i ud\b"),
MyRegEx(@"\b[Ss]lap i væk\b"),
MyRegEx(@"\b[Ss]nart er i\b"),
MyRegEx(@"\b[Ss]om i måske\b"),
MyRegEx(@"\b[Ss]om i nok\b"),
MyRegEx(@"\b[Ss]om i ved\b"),
MyRegEx(@"\b[Ss]pis i bare\b"),
MyRegEx(@"\b[Ss]pis i dem\b"),
MyRegEx(@"\b[Ss]ynes i at\b"),
MyRegEx(@"\b[Ss]ynes i det\b"),
MyRegEx(@"\b[Ss]ynes i,"),
MyRegEx(@"\b[Ss]ætter i en\b"),
MyRegEx(@"\bSå i at\b"),
MyRegEx(@"\bSå i det\b"),
MyRegEx(@"\bSå i noget\b"),
MyRegEx(@"\b[Ss]å tager i\b"),
MyRegEx(@"\bTænder i på\b"),
MyRegEx(@"\btænder i på\b"),
MyRegEx(@"\btog i bilen\b"),
MyRegEx(@"\bTog i bilen\b"),
MyRegEx(@"\btog i liften\b"),
MyRegEx(@"\bTog i liften\b"),
MyRegEx(@"\btog i toget\b"),
MyRegEx(@"\bTog i toget\b"),
MyRegEx(@"\btræder i frem\b"),
MyRegEx(@"\bTræder i frem\b"),
MyRegEx(@"\bTror i at\b"),
MyRegEx(@"\btror i at\b"),
MyRegEx(@"\btror i det\b"),
MyRegEx(@"\bTror i det\b"),
MyRegEx(@"\bTror i jeg\b"),
MyRegEx(@"\btror i jeg\b"),
MyRegEx(@"\bTror i på\b"),
MyRegEx(@"\b[Tr]ror i på\b"),
MyRegEx(@"\b[Tr]ror i, "),
MyRegEx(@"\b[Vv]ar i blevet\b"),
MyRegEx(@"\b[Vv]ed i alle\b"),
MyRegEx(@"\b[Vv]ed i allesammen\b"),
MyRegEx(@"\b[Vv]ed i er\b"),
MyRegEx(@"\b[Vv]ed i ikke\b"),
MyRegEx(@"\b[Vv]ed i hvad\b"),
MyRegEx(@"\b[Vv]ed i hvem\b"),
MyRegEx(@"\b[Vv]ed i hvor\b"),
MyRegEx(@"\b[Vv]ed i hvorfor\b"),
MyRegEx(@"\b[Vv]ed i hvordan\b"),
MyRegEx(@"\b[Vv]ed i var\b"),
MyRegEx(@"\b[Vv]ed i ville\b"),
MyRegEx(@"\b[Vv]ed i har\b"),
MyRegEx(@"\b[Vv]ed i havde\b"),
MyRegEx(@"\b[Vv]ed i hvem\b"),
MyRegEx(@"\b[Vv]ed i hvad\b"),
MyRegEx(@"\b[Vv]ed i hvor\b"),
MyRegEx(@"\b[Vv]ed i mente\b"),
MyRegEx(@"\b[Vv]ed i tror\b"),
MyRegEx(@"\b[Vv]enter i på\b"),
MyRegEx(@"\b[Vv]il i besegle\b"),
MyRegEx(@"\b[Vv]il i dræbe\b"),
MyRegEx(@"\b[Vv]il i fjerne\b"),
MyRegEx(@"\b[Vv]il i fortryde\b"),
MyRegEx(@"\b[Vv]il i gerne\b"),
MyRegEx(@"\b[Vv]il i godt\b"),
MyRegEx(@"\b[Vv]il i have\b"),
MyRegEx(@"\b[Vv]il i høre\b"),
MyRegEx(@"\b[Vv]il i ikke\b"),
MyRegEx(@"\b[Vv]il i købe\b"),
MyRegEx(@"\b[Vv]il i kaste\b"),
MyRegEx(@"\b[Vv]il i møde\b"),
MyRegEx(@"\b[Vv]il i måske\b"),
MyRegEx(@"\bvil i savne\b"),
MyRegEx(@"\bVil i savne\b"),
MyRegEx(@"\bvil i se\b"),
MyRegEx(@"\bVil i se\b"),
MyRegEx(@"\bvil i sikkert\b"),
MyRegEx(@"\bvil i smage\b"),
MyRegEx(@"\bVil i smage\b"),
MyRegEx(@"\b[Vv]il i virkelig\b"),
MyRegEx(@"\b[Vv]il i virkeligt\b"),
MyRegEx(@"\bVil i være\b"),
MyRegEx(@"\bvil i være\b"),
MyRegEx(@"\bVille i blive\b"),
MyRegEx(@"\bville i blive\b"),
MyRegEx(@"\bville i dræbe\b"),
MyRegEx(@"\bville i få\b"),
MyRegEx(@"\bville i få\b"),
MyRegEx(@"\bville i gøre\b"),
MyRegEx(@"\bville i høre\b"),
MyRegEx(@"\bville i ikke\b"),
MyRegEx(@"\bville i kaste\b"),
MyRegEx(@"\bville i komme\b"),
MyRegEx(@"\bville i mene\b"),
MyRegEx(@"\bville i nå\b"),
MyRegEx(@"\bville i savne\b"),
MyRegEx(@"\bVille i se\b"),
MyRegEx(@"\bville i se\b"),
MyRegEx(@"\bville i sikkert\b"),
MyRegEx(@"\bville i synes\b"),
MyRegEx(@"\bville i tage\b"),
MyRegEx(@"\bville i tro\b"),
MyRegEx(@"\bville i være\b"),
MyRegEx(@"\bville i være\b"),
MyRegEx(@"\b[Vv]iste i, at\b"),
MyRegEx(@"\b[Vv]iste i at\b"),
MyRegEx(@"\bvover i\b"),
};
var regExIDag = new Regex(@"\bidag\b", RegexOptions.Compiled);
var regExIGaar = new Regex(@"\bigår\b", RegexOptions.Compiled);
var regExIMorgen = new Regex(@"\bimorgen\b", RegexOptions.Compiled);
var regExIAlt = new Regex(@"\bialt\b", RegexOptions.Compiled);
var regExIGang = new Regex(@"\bigang\b", RegexOptions.Compiled);
var regExIStand = new Regex(@"\bistand\b", RegexOptions.Compiled);
var regExIOevrigt = new Regex(@"\biøvrigt\b", RegexOptions.Compiled);
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
string text = subtitle.Paragraphs[i].Text;
string oldText = text;
if (littleIRegex.IsMatch(text))
{
foreach (var regex in iList)
{
var match = regex.Match(text);
while (match.Success)
{
var iMatch = littleIRegex.Match(match.Value);
if (iMatch.Success)
{
string temp = match.Value.Remove(iMatch.Index, 1).Insert(iMatch.Index, "I");
int index = match.Index;
if (index + match.Value.Length >= text.Length)
text = text.Substring(0, index) + temp;
else
text = text.Substring(0, index) + temp + text.Substring(index + match.Value.Length);
}
match = match.NextMatch();
}
}
}
if (regExIDag.IsMatch(text))
text = regExIDag.Replace(text, "i dag");
if (regExIGaar.IsMatch(text))
text = regExIGaar.Replace(text, "i går");
if (regExIMorgen.IsMatch(text))
text = regExIMorgen.Replace(text, "i morgen");
if (regExIAlt.IsMatch(text))
text = regExIAlt.Replace(text, "i alt");
if (regExIGang.IsMatch(text))
text = regExIGang.Replace(text, "i gang");
if (regExIStand.IsMatch(text))
text = regExIStand.Replace(text, "i stand");
if (regExIOevrigt.IsMatch(text))
text = regExIOevrigt.Replace(text, "i øvrigt");
if (text != oldText)
{
subtitle.Paragraphs[i].Text = text;
fixCount++;
callbacks.AddFixToListView(subtitle.Paragraphs[i], fixAction, oldText, text);
}
}
callbacks.UpdateFixStatus(fixCount, language.FixDanishLetterI, string.Format(language.XIsChangedToUppercase, fixCount));
}
}
}

View File

@ -0,0 +1,25 @@
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixDialogsOnOneLine : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixDialogsOnOneLine;
int noOfFixes = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
string oldText = p.Text;
var text = Helper.FixDialogsOnOneLine(oldText, callbacks.Language);
if (oldText != text && callbacks.AllowFix(p, fixAction))
{
p.Text = text;
noOfFixes++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
callbacks.UpdateFixStatus(noOfFixes, language.FixCommonOcrErrors, language.FixDialogsOneLineExample);
}
}
}

View File

@ -0,0 +1,28 @@
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixDoubleApostrophes : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixDoubleApostrophes;
int fixCount = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
if (p.Text.Contains("''"))
{
if (callbacks.AllowFix(p, fixAction))
{
string oldText = p.Text;
p.Text = p.Text.Replace("''", "\"");
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
fixCount++;
}
}
}
callbacks.UpdateFixStatus(fixCount, language.FixDoubleApostrophes, language.XDoubleApostrophesFixed);
}
}
}

View File

@ -0,0 +1,81 @@
using System;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixDoubleDash : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixDoubleDash;
int fixCount = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
if (callbacks.AllowFix(p, fixAction))
{
string text = p.Text;
string oldText = p.Text;
while (text.Contains("---", StringComparison.Ordinal))
{
text = text.Replace("---", "--");
}
if (text.Contains("--", StringComparison.Ordinal))
{
text = text.Replace("--", "... ");
text = text.Replace("... ", "... ");
text = text.Replace(" ...", "...");
text = text.TrimEnd();
text = text.Replace("... " + Environment.NewLine, "..." + Environment.NewLine);
text = text.Replace("... </", "...</"); // </i>, </font>...
text = text.Replace("... ?", "...?");
text = text.Replace("... !", "...!");
if (text.IndexOf(Environment.NewLine, StringComparison.Ordinal) > 1)
{
var lines = text.SplitToLines();
for (int k = 0; k < lines.Length; k++)
lines[k] = Helper.RemoveSpacesBeginLineAfterEllipses(lines[k]);
text = string.Join(Environment.NewLine, lines);
}
else
{
text = Helper.RemoveSpacesBeginLineAfterEllipses(text);
}
}
//if (text.EndsWith('-'))
//{
// text = text.Substring(0, text.Length - 1) + "...";
// text = text.Replace(" ...", "...");
//}
//if (text.EndsWith("-</i>"))
//{
// text = text.Replace("-</i>", "...</i>");
// text = text.Replace(" ...", "...");
//}
if (text.StartsWith('—') && text.Length > 1)
{
text = text.Substring(1).Insert(0, "...");
}
if (text.EndsWith('—') && text.Length > 1)
{
text = text.Substring(0, text.Length - 1) + "...";
text = text.Replace(" ...", "...");
}
if (text != oldText)
{
p.Text = text;
fixCount++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
}
callbacks.UpdateFixStatus(fixCount, language.FixDoubleDash, language.XFixDoubleDash);
}
}
}

View File

@ -0,0 +1,52 @@
using System;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixDoubleGreaterThan : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixDoubleGreaterThan;
int fixCount = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
if (callbacks.AllowFix(p, fixAction))
{
if (!p.Text.Contains(">>", StringComparison.Ordinal))
continue;
var text = p.Text;
var oldText = text;
if (!text.Contains(Environment.NewLine))
{
text = Helper.FixDoubleGreaterThanHelper(text);
if (oldText != text)
{
fixCount++;
p.Text = text;
callbacks.AddFixToListView(p, fixAction, oldText, text);
}
}
else
{
var lines = text.SplitToLines();
for (int k = 0; k < lines.Length; k++)
{
lines[k] = Helper.FixDoubleGreaterThanHelper(lines[k]);
}
text = string.Join(Environment.NewLine, lines);
if (oldText != text)
{
fixCount++;
p.Text = text;
callbacks.AddFixToListView(p, fixAction, oldText, text);
}
}
}
}
callbacks.UpdateFixStatus(fixCount, language.FixDoubleGreaterThan, language.XFixDoubleGreaterThan);
}
}
}

View File

@ -0,0 +1,53 @@
using System;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixEllipsesStart : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixEllipsesStart;
int fixCount = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
var text = p.Text;
if (text.Contains("..") && callbacks.AllowFix(p, fixAction))
{
var oldText = text;
if (!text.Contains(Environment.NewLine))
{
text = Helper.FixEllipsesStartHelper(text);
if (oldText != text)
{
p.Text = text;
fixCount++;
callbacks.AddFixToListView(p, fixAction, oldText, text);
}
}
else
{
var lines = text.SplitToLines();
var fixedParagraph = string.Empty;
for (int k = 0; k < lines.Length; k++)
{
var line = lines[k];
fixedParagraph += Environment.NewLine + Helper.FixEllipsesStartHelper(line);
fixedParagraph = fixedParagraph.Trim();
}
if (fixedParagraph != text)
{
p.Text = fixedParagraph;
fixCount++;
callbacks.AddFixToListView(p, fixAction, oldText, fixedParagraph);
}
}
}
}
callbacks.UpdateFixStatus(fixCount, language.FixEllipsesStart, language.XFixEllipsesStart);
}
}
}

View File

@ -111,14 +111,13 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
subtitle.Paragraphs.RemoveAt(i);
emptyLinesRemoved++;
callbacks.AddFixToListView(p, fixAction0, p.Text, string.Format("[{0}]", language.RemovedEmptyLine));
callbacks.AddtoDeleteIndices(i);
callbacks.AddToDeleteIndices(i);
}
}
if (emptyLinesRemoved > 0)
{
callbacks.LogStatus(language.RemovedEmptyLinesUnsedLineBreaks, string.Format(language.EmptyLinesRemovedX, emptyLinesRemoved));
callbacks.AddToTotalFixes(emptyLinesRemoved);
callbacks.UpdateFixStatus(emptyLinesRemoved, language.RemovedEmptyLinesUnsedLineBreaks, string.Format(language.EmptyLinesRemovedX, emptyLinesRemoved));
subtitle.Renumber();
}
}

View File

@ -0,0 +1,30 @@

namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixHyphensAdd : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixHyphen;
int iFixes = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
var p = subtitle.Paragraphs[i];
if (callbacks.AllowFix(p, fixAction))
{
string oldText = p.Text;
string text = Helper.FixHyphensAdd(subtitle, i, callbacks.Language);
if (text != oldText)
{
p.Text = text;
iFixes++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
}
callbacks.UpdateFixStatus(iFixes, language.FixHyphen, language.XHyphensFixed);
}
}
}

View File

@ -0,0 +1,29 @@

namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixHyphensRemove : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixHyphen;
int iFixes = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
var p = subtitle.Paragraphs[i];
if (callbacks.AllowFix(p, fixAction))
{
string oldText = p.Text;
string text = Helper.FixHyphensRemove(subtitle, i);
if (text != oldText)
{
p.Text = text;
iFixes++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
}
callbacks.UpdateFixStatus(iFixes, language.FixHyphens, language.XHyphensFixed);
}
}
}

View File

@ -31,11 +31,8 @@
}
}
}
if (noOfInvalidHtmlTags > 0)
{
callbacks.AddToTotalFixes(noOfInvalidHtmlTags);
callbacks.LogStatus(language.FixInvalidItalicTags, string.Format(language.XInvalidHtmlTagsFixed, noOfInvalidHtmlTags));
}
callbacks.UpdateFixStatus(noOfInvalidHtmlTags, language.FixInvalidItalicTags, string.Format(language.XInvalidHtmlTagsFixed, noOfInvalidHtmlTags));
}
}

View File

@ -32,11 +32,8 @@
callbacks.AddFixToListView(p, fixAction, oldCurrent, p.ToString());
}
}
if (noOfLongDisplayTimes > 0)
{
callbacks.AddToTotalFixes(noOfLongDisplayTimes);
callbacks.LogStatus(language.FixLongDisplayTimes, string.Format(language.XDisplayTimesShortned, noOfLongDisplayTimes));
}
callbacks.UpdateFixStatus(noOfLongDisplayTimes, language.FixLongDisplayTimes, string.Format(language.XDisplayTimesShortned, noOfLongDisplayTimes));
}
}

View File

@ -32,12 +32,12 @@
else
{
callbacks.LogStatus(fixAction, string.Format(language.UnableToFixTextXY, i + 1, p));
callbacks.AddtoTotalErrors(1);
callbacks.AddToTotalErrors(1);
}
}
}
if (noOfLongLines > 0)
callbacks.LogStatus(language.BreakLongLines, string.Format(language.XLineBreaksAdded, noOfLongLines));
callbacks.UpdateFixStatus(noOfLongLines, language.BreakLongLines, string.Format(language.XLineBreaksAdded, noOfLongLines));
}
}
}

View File

@ -0,0 +1,89 @@
using System;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixMissingOpenBracket : IFixCommonError
{
private static string Fix(string text, string openB)
{
string pre = string.Empty;
string closeB = openB == "(" ? ")" : "]";
if (text.Contains(" " + closeB))
openB = openB + " ";
do
{
if (text.Length > 1 && text.StartsWith('-'))
{
pre += "- ";
if (text[1] == ' ')
text = text.Substring(2);
else
text = text.Substring(1);
}
if (text.Length > 3 && text.StartsWith("<i>", StringComparison.OrdinalIgnoreCase))
{
pre += "<i>";
if (text[3] == ' ')
text = text.Substring(4);
else
text = text.Substring(3);
}
if (text.Length > 1 && (text[0] == ' ' || text[0] == '.'))
{
pre += text[0] == '.' ? '.' : ' ';
text = text.Substring(1);
while (text.Length > 0 && text[0] == '.')
{
pre += ".";
text = text.Substring(1);
}
text = text.TrimStart(' ');
}
} while (text.StartsWith("<i>", StringComparison.Ordinal) || text.StartsWith('-'));
text = pre + openB + text;
return text;
}
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixMissingOpenBracket;
int fixCount = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
var p = subtitle.Paragraphs[i];
if (callbacks.AllowFix(p, fixAction))
{
var hit = false;
string oldText = p.Text;
var openIdx = p.Text.IndexOf('(');
var closeIdx = p.Text.IndexOf(')');
if (closeIdx >= 0 && (closeIdx < openIdx || openIdx < 0))
{
p.Text = Fix(p.Text, "(");
hit = true;
}
openIdx = p.Text.IndexOf('[');
closeIdx = p.Text.IndexOf(']');
if (closeIdx >= 0 && (closeIdx < openIdx || openIdx < 0))
{
p.Text = Fix(p.Text, "[");
hit = true;
}
if (hit)
{
fixCount++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
}
callbacks.UpdateFixStatus(fixCount, language.FixMissingOpenBracket, language.XFixMissingOpenBracket);
}
}
}

View File

@ -0,0 +1,148 @@
using System;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixMissingPeriodsAtEndOfLine : IFixCommonError
{
private static readonly char[] WordSplitChars = { ' ', '.', ',', '-', '?', '!', ':', ';', '"', '(', ')', '[', ']', '{', '}', '|', '<', '>', '/', '+', '\r', '\n' };
private static bool IsOneLineUrl(string s)
{
if (s.Contains(' ') || s.Contains(Environment.NewLine))
return false;
if (s.StartsWith("http://", StringComparison.OrdinalIgnoreCase))
return true;
if (s.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
return true;
if (s.StartsWith("www.", StringComparison.OrdinalIgnoreCase))
return true;
string[] parts = s.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 3 && parts[2].Length > 1 && parts[2].Length < 7)
return true;
return false;
}
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixMissingPeriodAtEndOfLine;
int missigPeriodsAtEndOfLine = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
Paragraph next = subtitle.GetParagraphOrDefault(i + 1);
string nextText = string.Empty;
if (next != null)
nextText = HtmlUtil.RemoveHtmlTags(next.Text).TrimStart('-', '"', '„').TrimStart();
string tempNoHtml = HtmlUtil.RemoveHtmlTags(p.Text).TrimEnd();
if (IsOneLineUrl(p.Text) || p.Text.Contains(new[] { '♪', '♫' }) || p.Text.EndsWith('\''))
{
// ignore urls
}
else if (!string.IsNullOrEmpty(nextText) && next != null &&
next.Text.Length > 0 &&
Utilities.UppercaseLetters.Contains(nextText[0]) &&
tempNoHtml.Length > 0 &&
!@",.!?:;>-])♪♫…".Contains(tempNoHtml[tempNoHtml.Length - 1]))
{
string tempTrimmed = tempNoHtml.TrimEnd().TrimEnd('\'', '"', '“', '”').TrimEnd();
if (tempTrimmed.Length > 0 && !@")]*#¶.!?".Contains(tempTrimmed[tempTrimmed.Length - 1]) && p.Text != p.Text.ToUpper())
{
//don't end the sentence if the next word is an I word as they're always capped.
if (!next.Text.StartsWith("I ", StringComparison.Ordinal) && !next.Text.StartsWith("I'", StringComparison.Ordinal))
{
//test to see if the first word of the next line is a name
if (!callbacks.IsName(next.Text.Split(WordSplitChars)[0]) && callbacks.AllowFix(p, fixAction))
{
string oldText = p.Text;
if (p.Text.EndsWith('>'))
{
int lastLessThan = p.Text.LastIndexOf('<');
if (lastLessThan > 0)
p.Text = p.Text.Insert(lastLessThan, ".");
}
else
{
if (p.Text.EndsWith('“') && tempNoHtml.StartsWith('„'))
p.Text = p.Text.TrimEnd('“') + ".“";
else if (p.Text.EndsWith('"') && tempNoHtml.StartsWith('"'))
p.Text = p.Text.TrimEnd('"') + ".\"";
else
p.Text += ".";
}
if (p.Text != oldText)
{
missigPeriodsAtEndOfLine++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
}
}
}
else if (next != null && !string.IsNullOrEmpty(p.Text) && Utilities.AllLettersAndNumbers.Contains(p.Text[p.Text.Length - 1]))
{
if (p.Text != p.Text.ToUpper())
{
var st = new StripableText(next.Text);
if (st.StrippedText.Length > 0 && st.StrippedText != st.StrippedText.ToUpper() &&
Utilities.UppercaseLetters.Contains(st.StrippedText[0]))
{
if (callbacks.AllowFix(p, fixAction))
{
int j = p.Text.Length - 1;
while (j >= 0 && !@".!?¿¡".Contains(p.Text[j]))
j--;
string endSign = ".";
if (j >= 0 && p.Text[j] == '¿')
endSign = "?";
if (j >= 0 && p.Text[j] == '¡')
endSign = "!";
string oldText = p.Text;
missigPeriodsAtEndOfLine++;
p.Text += endSign;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
}
}
if (p.Text.Length > 4)
{
int indexOfNewLine = p.Text.IndexOf(Environment.NewLine + " -", 3, StringComparison.Ordinal);
if (indexOfNewLine < 0)
indexOfNewLine = p.Text.IndexOf(Environment.NewLine + "-", 3, StringComparison.Ordinal);
if (indexOfNewLine < 0)
indexOfNewLine = p.Text.IndexOf(Environment.NewLine + "<i>-", 3, StringComparison.Ordinal);
if (indexOfNewLine < 0)
indexOfNewLine = p.Text.IndexOf(Environment.NewLine + "<i> -", 3, StringComparison.Ordinal);
if (indexOfNewLine > 0 && Configuration.Settings.General.UppercaseLetters.Contains(char.ToUpper(p.Text[indexOfNewLine - 1])) && callbacks.AllowFix(p, fixAction))
{
string oldText = p.Text;
string text = p.Text.Substring(0, indexOfNewLine);
var st = new StripableText(text);
if (st.Pre.TrimEnd().EndsWith('¿')) // Spanish ¿
p.Text = p.Text.Insert(indexOfNewLine, "?");
else if (st.Pre.TrimEnd().EndsWith('¡')) // Spanish ¡
p.Text = p.Text.Insert(indexOfNewLine, "!");
else
p.Text = p.Text.Insert(indexOfNewLine, ".");
missigPeriodsAtEndOfLine++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
}
callbacks.UpdateFixStatus(missigPeriodsAtEndOfLine, language.AddPeriods, language.XPeriodsAdded);
}
}
}

View File

@ -309,11 +309,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
}
}
}
if (missingSpaces > 0)
{
callbacks.AddToTotalFixes(missingSpaces);
callbacks.LogStatus(language.FixMissingSpaces, string.Format(language.XMissingSpacesAdded, missingSpaces));
}
callbacks.UpdateFixStatus(missingSpaces, language.FixMissingSpaces, string.Format(language.XMissingSpacesAdded, missingSpaces));
}
private static string GetWordFromIndex(string text, int index)

View File

@ -0,0 +1,38 @@
using System;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixMusicNotation : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixMusicNotation;
int fixCount = 0;
string[] musicSymbols = Configuration.Settings.Tools.MusicSymbolToReplace.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
if (callbacks.AllowFix(p, fixAction))
{
var oldText = p.Text;
var newText = oldText;
foreach (string musicSymbol in musicSymbols)
{
newText = newText.Replace(musicSymbol, Configuration.Settings.Tools.MusicSymbol);
newText = newText.Replace(musicSymbol.ToUpper(), Configuration.Settings.Tools.MusicSymbol);
}
var noTagsText = HtmlUtil.RemoveHtmlTags(newText);
if (newText != oldText && noTagsText != HtmlUtil.RemoveHtmlTags(oldText))
{
p.Text = newText;
fixCount++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
}
callbacks.UpdateFixStatus(fixCount, language.FixMusicNotation, language.XFixMusicNotation);
}
}
}

View File

@ -55,7 +55,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
else
{
callbacks.LogStatus(language.FixOverlappingDisplayTimes, string.Format(language.UnableToFixStartTimeLaterThanEndTime, i + 1, p), true);
callbacks.AddtoTotalErrors(1);
callbacks.AddToTotalErrors(1);
}
if (isFixed)
@ -223,17 +223,13 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
if (callbacks.AllowFix(p, fixAction))
{
callbacks.LogStatus(language.FixOverlappingDisplayTimes, string.Format(language.UnableToFixTextXY, i + 1, Environment.NewLine + prev.Number + " " + prev + Environment.NewLine + p.Number + " " + p), true);
callbacks.AddtoTotalErrors(1);
callbacks.AddToTotalErrors(1);
}
}
}
}
if (noOfOverlappingDisplayTimesFixed > 0)
{
callbacks.AddToTotalFixes(noOfOverlappingDisplayTimesFixed);
callbacks.LogStatus(fixAction, string.Format(language.XOverlappingTimestampsFixed, noOfOverlappingDisplayTimesFixed));
}
callbacks.UpdateFixStatus(noOfOverlappingDisplayTimesFixed, fixAction, string.Format(language.XOverlappingTimestampsFixed, noOfOverlappingDisplayTimesFixed));
}
}

View File

@ -51,7 +51,7 @@
else
{
callbacks.LogStatus(language.FixShortDisplayTimes, string.Format(language.UnableToFixTextXY, i + 1, p));
callbacks.AddtoTotalErrors(1);
callbacks.AddToTotalErrors(1);
skip = true;
}
}
@ -141,15 +141,11 @@
else
{
callbacks.LogStatus(language.FixShortDisplayTimes, string.Format(language.UnableToFixTextXY, i + 1, p));
callbacks.AddtoTotalErrors(1);
callbacks.AddToTotalErrors(1);
}
}
}
if (noOfShortDisplayTimes > 0)
{
callbacks.AddToTotalFixes(noOfShortDisplayTimes);
callbacks.LogStatus(fixAction, string.Format(language.XDisplayTimesProlonged, noOfShortDisplayTimes));
}
callbacks.UpdateFixStatus(noOfShortDisplayTimes, fixAction, string.Format(language.XDisplayTimesProlonged, noOfShortDisplayTimes));
}
private int MoveStartTime(string fixAction, int noOfShortDisplayTimes, Paragraph p, Paragraph temp, Paragraph next)

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixShortLines : IFixCommonError
{
@ -24,11 +19,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
if (noOfShortLines > 0)
{
callbacks.AddToTotalFixes(noOfShortLines);
callbacks.LogStatus(language.RemoveLineBreaks, string.Format(language.XLinesUnbreaked, noOfShortLines));
}
callbacks.UpdateFixStatus(noOfShortLines, language.RemoveLineBreaks, string.Format(language.XLinesUnbreaked, noOfShortLines));
}
}
}

View File

@ -0,0 +1,34 @@
using System;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixShortLinesAll : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.MergeShortLineAll;
int noOfShortLines = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
if (callbacks.AllowFix(p, fixAction))
{
string s = HtmlUtil.RemoveHtmlTags(p.Text, true);
if (s.Replace(Environment.NewLine, " ").Replace(" ", " ").Length < Configuration.Settings.Tools.MergeLinesShorterThan && p.Text.Contains(Environment.NewLine))
{
s = Utilities.AutoBreakLine(p.Text, callbacks.Language);
if (s != p.Text)
{
string oldCurrent = p.Text;
p.Text = s;
noOfShortLines++;
callbacks.AddFixToListView(p, fixAction, oldCurrent, p.Text);
}
}
}
}
callbacks.UpdateFixStatus(noOfShortLines, language.RemoveLineBreaks, string.Format(language.XLinesUnbreaked, noOfShortLines));
}
}
}

View File

@ -0,0 +1,232 @@
using System;
using System.Collections.Generic;
using System.Globalization;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
/// <summary>
/// Will try to fix issues with Spanish special letters ¿? and ¡!.
/// Sentences ending with "?" must start with "¿".
/// Sentences ending with "!" must start with "¡".
/// </summary>
public class FixSpanishInvertedQuestionAndExclamationMarks : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixSpanishInvertedQuestionAndExclamationMarks;
int fixCount = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
Paragraph last = subtitle.GetParagraphOrDefault(i - 1);
bool wasLastLineClosed = last == null || last.Text.EndsWith('?') || last.Text.EndsWith('!') || last.Text.EndsWith('.') ||
last.Text.EndsWith(':') || last.Text.EndsWith(')') || last.Text.EndsWith(']');
string trimmedStart = p.Text.TrimStart('-', ' ');
if (last != null && last.Text.EndsWith("...", StringComparison.Ordinal) && trimmedStart.Length > 0 && char.IsLower(trimmedStart[0]))
wasLastLineClosed = false;
if (!wasLastLineClosed && last.Text == last.Text.ToUpper())
wasLastLineClosed = true;
string oldText = p.Text;
FixSpanishInvertedLetter('?', "¿", p, last, ref wasLastLineClosed, fixAction, ref fixCount, callbacks);
FixSpanishInvertedLetter('!', "¡", p, last, ref wasLastLineClosed, fixAction, ref fixCount, callbacks);
if (p.Text != oldText)
{
fixCount++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
callbacks.UpdateFixStatus(fixCount, language.FixSpanishInvertedQuestionAndExclamationMarks, fixCount.ToString(CultureInfo.InvariantCulture));
}
private void FixSpanishInvertedLetter(char mark, string inverseMark, Paragraph p, Paragraph last, ref bool wasLastLineClosed, string fixAction, ref int fixCount, IFixCallbacks callbacks)
{
if (p.Text.Contains(mark))
{
bool skip = false;
if (last != null && p.Text.Contains(mark) && !p.Text.Contains(inverseMark) && last.Text.Contains(inverseMark) && !last.Text.Contains(mark))
skip = true;
if (!skip && Utilities.CountTagInText(p.Text, mark) == Utilities.CountTagInText(p.Text, inverseMark) &&
HtmlUtil.RemoveHtmlTags(p.Text).TrimStart(inverseMark[0]).Contains(inverseMark) == false &&
HtmlUtil.RemoveHtmlTags(p.Text).TrimEnd(mark).Contains(mark) == false)
{
skip = true;
}
if (!skip)
{
int startIndex = 0;
int markIndex = p.Text.IndexOf(mark);
if (!wasLastLineClosed && ((p.Text.IndexOf('!') > 0 && p.Text.IndexOf('!') < markIndex) ||
(p.Text.IndexOf('?') > 0 && p.Text.IndexOf('?') < markIndex) ||
(p.Text.IndexOf('.') > 0 && p.Text.IndexOf('.') < markIndex)))
wasLastLineClosed = true;
while (markIndex > 0 && startIndex < p.Text.Length)
{
int inverseMarkIndex = p.Text.IndexOf(inverseMark, startIndex, StringComparison.Ordinal);
if (wasLastLineClosed && (inverseMarkIndex < 0 || inverseMarkIndex > markIndex))
{
if (callbacks.AllowFix(p, fixAction))
{
int j = markIndex - 1;
while (j > startIndex && (p.Text[j] == '.' || p.Text[j] == '!' || p.Text[j] == '?'))
j--;
while (j > startIndex &&
(p.Text[j] != '.' || IsSpanishAbbreviation(p.Text, j, callbacks)) &&
p.Text[j] != '!' &&
p.Text[j] != '?' &&
!(j > 3 && p.Text.Substring(j - 3, 3) == Environment.NewLine + "-") &&
!(j > 4 && p.Text.Substring(j - 4, 4) == Environment.NewLine + " -") &&
!(j > 6 && p.Text.Substring(j - 6, 6) == Environment.NewLine + "<i>-"))
j--;
if (@".!?".Contains(p.Text[j]))
{
j++;
}
if (j + 3 < p.Text.Length && p.Text.Substring(j + 1, 2) == Environment.NewLine)
{
j += 3;
}
else if (j + 2 < p.Text.Length && p.Text.Substring(j, 2) == Environment.NewLine)
{
j += 2;
}
if (j >= startIndex)
{
string part = p.Text.Substring(j, markIndex - j + 1);
string speaker = string.Empty;
int speakerEnd = part.IndexOf(')');
if (part.StartsWith('(') && speakerEnd > 0 && speakerEnd < part.IndexOf(mark))
{
while (Environment.NewLine.Contains(part[speakerEnd + 1]))
speakerEnd++;
speaker = part.Substring(0, speakerEnd + 1);
part = part.Substring(speakerEnd + 1);
}
speakerEnd = part.IndexOf(']');
if (part.StartsWith('[') && speakerEnd > 0 && speakerEnd < part.IndexOf(mark))
{
while (Environment.NewLine.Contains(part[speakerEnd + 1]))
speakerEnd++;
speaker = part.Substring(0, speakerEnd + 1);
part = part.Substring(speakerEnd + 1);
}
var st = new StripableText(part);
if (j == 0 && mark == '!' && st.Pre == "¿" && Utilities.CountTagInText(p.Text, mark) == 1 && HtmlUtil.RemoveHtmlTags(p.Text).EndsWith(mark))
{
p.Text = inverseMark + p.Text;
}
else if (j == 0 && mark == '?' && st.Pre == "¡" && Utilities.CountTagInText(p.Text, mark) == 1 && HtmlUtil.RemoveHtmlTags(p.Text).EndsWith(mark))
{
p.Text = inverseMark + p.Text;
}
else
{
string temp = inverseMark;
int addToIndex = 0;
while (p.Text.Length > markIndex + 1 && p.Text[markIndex + 1] == mark &&
Utilities.CountTagInText(p.Text, mark) > Utilities.CountTagInText(p.Text + temp, inverseMark))
{
temp += inverseMark;
st.Post += mark;
markIndex++;
addToIndex++;
}
p.Text = p.Text.Remove(j, markIndex - j + 1).Insert(j, speaker + st.Pre + temp + st.StrippedText + st.Post);
markIndex += addToIndex;
}
}
}
}
else if (last != null && !wasLastLineClosed && inverseMarkIndex == p.Text.IndexOf(mark) && !last.Text.Contains(inverseMark))
{
string lastOldtext = last.Text;
int idx = last.Text.Length - 2;
while (idx > 0 && (last.Text.Substring(idx, 2) != ". ") && (last.Text.Substring(idx, 2) != "! ") && (last.Text.Substring(idx, 2) != "? "))
idx--;
last.Text = last.Text.Insert(idx, inverseMark);
fixCount++;
callbacks.AddFixToListView(last, fixAction, lastOldtext, last.Text);
}
startIndex = markIndex + 2;
if (startIndex < p.Text.Length)
markIndex = p.Text.IndexOf(mark, startIndex);
else
markIndex = -1;
wasLastLineClosed = true;
}
}
if (p.Text.EndsWith(mark + "...", StringComparison.Ordinal) && p.Text.Length > 4)
{
p.Text = p.Text.Remove(p.Text.Length - 4, 4) + "..." + mark;
}
}
else if (Utilities.CountTagInText(p.Text, inverseMark) == 1)
{
int idx = p.Text.IndexOf(inverseMark, StringComparison.Ordinal);
while (idx < p.Text.Length && !@".!?".Contains(p.Text[idx]))
{
idx++;
}
if (idx < p.Text.Length)
{
p.Text = p.Text.Insert(idx, mark.ToString(CultureInfo.InvariantCulture));
if (p.Text.Contains("¡¿") && p.Text.Contains("!?"))
p.Text = p.Text.Replace("!?", "?!");
if (p.Text.Contains("¿¡") && p.Text.Contains("?!"))
p.Text = p.Text.Replace("?!", "!?");
}
}
}
private bool IsSpanishAbbreviation(string text, int index, IFixCallbacks callbacks)
{
if (text[index] != '.')
return false;
if (index + 3 < text.Length && text[index + 2] == '.') // X
return true; // O.R.
if (index - 3 > 0 && text[index - 1] != '.' && text[index - 2] == '.') // X
return true; // O.R.
string word = string.Empty;
int i = index - 1;
while (i >= 0 && Utilities.AllLetters.Contains(text[i]))
{
word = text[i] + word;
i--;
}
//Common Spanish abbreviations
//Dr. (same as English)
//Sr. (same as Mr.)
//Sra. (same as Mrs.)
//Ud.
//Uds.
if (word.Equals("dr", StringComparison.OrdinalIgnoreCase) ||
word.Equals("sr", StringComparison.OrdinalIgnoreCase) ||
word.Equals("sra", StringComparison.OrdinalIgnoreCase) ||
word.Equals("ud", StringComparison.OrdinalIgnoreCase) ||
word.Equals("uds", StringComparison.OrdinalIgnoreCase))
return true;
List<string> abbreviations = callbacks.GetAbbreviations();
return abbreviations.Contains(word + ".");
}
}
}

View File

@ -0,0 +1,90 @@
using System;
using System.Globalization;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixStartWithUppercaseLetterAfterColon : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.StartWithUppercaseLetterAfterColon;
int noOfFixes = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
var p = new Paragraph(subtitle.Paragraphs[i]);
Paragraph last = subtitle.GetParagraphOrDefault(i - 1);
string oldText = p.Text;
int skipCount = 0;
if (last != null)
{
string lastText = HtmlUtil.RemoveHtmlTags(last.Text);
if (lastText.EndsWith(':') || lastText.EndsWith(';'))
{
var st = new StripableText(p.Text);
if (st.StrippedText.Length > 0 && st.StrippedText[0] != char.ToUpper(st.StrippedText[0]))
p.Text = st.Pre + char.ToUpper(st.StrippedText[0]) + st.StrippedText.Substring(1) + st.Post;
}
}
if (oldText.Contains(new[] { ':', ';' }))
{
bool lastWasColon = false;
for (int j = 0; j < p.Text.Length; j++)
{
var s = p.Text[j];
if (s == ':' || s == ';')
{
lastWasColon = true;
}
else if (lastWasColon)
{
var startFromJ = p.Text.Substring(j);
if (skipCount > 0)
skipCount--;
else if (startFromJ.StartsWith("<i>", StringComparison.OrdinalIgnoreCase))
skipCount = 2;
else if (startFromJ.StartsWith("<b>", StringComparison.OrdinalIgnoreCase))
skipCount = 2;
else if (startFromJ.StartsWith("<u>", StringComparison.OrdinalIgnoreCase))
skipCount = 2;
else if (startFromJ.StartsWith("<font ", StringComparison.OrdinalIgnoreCase) && p.Text.Substring(j).Contains('>'))
skipCount = startFromJ.IndexOf('>') - startFromJ.IndexOf("<font ", StringComparison.OrdinalIgnoreCase);
else if (Helper.IsTurkishLittleI(s, callbacks.Encoding, callbacks.Language))
{
p.Text = p.Text.Remove(j, 1).Insert(j, Helper.GetTurkishUppercaseLetter(s, callbacks.Encoding).ToString(CultureInfo.InvariantCulture));
lastWasColon = false;
}
else if (char.IsLower(s))
{
// iPhone
bool change = true;
if (s == 'i' && p.Text.Length > j + 1)
{
if (p.Text[j + 1] == char.ToUpper(p.Text[j + 1]))
change = false;
}
if (change)
p.Text = p.Text.Remove(j, 1).Insert(j, char.ToUpper(s).ToString(CultureInfo.InvariantCulture));
lastWasColon = false;
}
else if (!(" " + Environment.NewLine).Contains(s))
lastWasColon = false;
}
}
}
if (oldText != p.Text && callbacks.AllowFix(p, fixAction))
{
noOfFixes++;
subtitle.Paragraphs[i].Text = p.Text;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
callbacks.UpdateFixStatus(noOfFixes, language.StartWithUppercaseLetterAfterColon, noOfFixes.ToString(CultureInfo.InvariantCulture));
}
}
}

View File

@ -0,0 +1,280 @@
using System;
using System.Globalization;
using System.Text;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixStartWithUppercaseLetterAfterParagraph : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixFirstLetterToUppercaseAfterParagraph;
int fixedStartWithUppercaseLetterAfterParagraphTicked = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
Paragraph prev = subtitle.GetParagraphOrDefault(i - 1);
string oldText = p.Text;
string fixedText = DoFix(new Paragraph(p), prev, callbacks.Encoding, callbacks.Language);
if (oldText != fixedText && callbacks.AllowFix(p, fixAction))
{
p.Text = fixedText;
fixedStartWithUppercaseLetterAfterParagraphTicked++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
callbacks.UpdateFixStatus(fixedStartWithUppercaseLetterAfterParagraphTicked, language.StartWithUppercaseLetterAfterParagraph, fixedStartWithUppercaseLetterAfterParagraphTicked.ToString(CultureInfo.InvariantCulture));
}
private static string DoFix(Paragraph p, Paragraph prev, Encoding encoding, string language)
{
if (p.Text != null && p.Text.Length > 1)
{
string text = p.Text;
string pre = string.Empty;
if (text.Length > 4 && text.StartsWith("<i> ", StringComparison.Ordinal))
{
pre = "<i> ";
text = text.Substring(4);
}
if (text.Length > 3 && text.StartsWith("<i>", StringComparison.Ordinal))
{
pre = "<i>";
text = text.Substring(3);
}
if (text.Length > 4 && text.StartsWith("<I> ", StringComparison.Ordinal))
{
pre = "<I> ";
text = text.Substring(4);
}
if (text.Length > 3 && text.StartsWith("<I>", StringComparison.Ordinal))
{
pre = "<I>";
text = text.Substring(3);
}
if (text.Length > 2 && text.StartsWith('♪'))
{
pre = pre + "♪";
text = text.Substring(1);
}
if (text.Length > 2 && text.StartsWith(' '))
{
pre = pre + " ";
text = text.Substring(1);
}
if (text.Length > 2 && text.StartsWith('♫'))
{
pre = pre + "♫";
text = text.Substring(1);
}
if (text.Length > 2 && text.StartsWith(' '))
{
pre = pre + " ";
text = text.Substring(1);
}
var firstLetter = text[0];
string prevText = " .";
if (prev != null)
prevText = HtmlUtil.RemoveHtmlTags(prev.Text);
bool isPrevEndOfLine = Helper.IsPreviousTextEndOfParagraph(prevText);
if (prevText == " .")
isPrevEndOfLine = true;
if ((!text.StartsWith("www.", StringComparison.Ordinal) && !text.StartsWith("http:", StringComparison.Ordinal) && !text.StartsWith("https:", StringComparison.Ordinal)) &&
(char.IsLower(firstLetter) || Helper.IsTurkishLittleI(firstLetter, encoding, language)) &&
!char.IsDigit(firstLetter) &&
isPrevEndOfLine)
{
bool isMatchInKnowAbbreviations = language == "en" &&
(prevText.EndsWith(" o.r.", StringComparison.Ordinal) ||
prevText.EndsWith(" a.m.", StringComparison.Ordinal) ||
prevText.EndsWith(" p.m.", StringComparison.Ordinal));
if (!isMatchInKnowAbbreviations)
{
if (Helper.IsTurkishLittleI(firstLetter, encoding, language))
p.Text = pre + Helper.GetTurkishUppercaseLetter(firstLetter, encoding) + text.Substring(1);
else if (language == "en" && (text.StartsWith("l ", StringComparison.Ordinal) || text.StartsWith("l-I", StringComparison.Ordinal) || text.StartsWith("ls ", StringComparison.Ordinal) || text.StartsWith("lnterested") ||
text.StartsWith("lsn't ", StringComparison.Ordinal) || text.StartsWith("ldiot", StringComparison.Ordinal) || text.StartsWith("ln", StringComparison.Ordinal) || text.StartsWith("lm", StringComparison.Ordinal) ||
text.StartsWith("ls", StringComparison.Ordinal) || text.StartsWith("lt", StringComparison.Ordinal) || text.StartsWith("lf ", StringComparison.Ordinal) || text.StartsWith("lc", StringComparison.Ordinal) || text.StartsWith("l'm ", StringComparison.Ordinal)) || text.StartsWith("l am ", StringComparison.Ordinal)) // l > I
p.Text = pre + "I" + text.Substring(1);
else
p.Text = pre + char.ToUpper(firstLetter) + text.Substring(1);
}
}
}
if (p.Text != null && p.Text.Contains(Environment.NewLine))
{
var arr = p.Text.SplitToLines();
if (arr.Length == 2 && arr[1].Length > 1)
{
string text = arr[1];
string pre = string.Empty;
if (text.Length > 4 && text.StartsWith("<i> ", StringComparison.Ordinal))
{
pre = "<i> ";
text = text.Substring(4);
}
if (text.Length > 3 && text.StartsWith("<i>", StringComparison.Ordinal))
{
pre = "<i>";
text = text.Substring(3);
}
if (text.Length > 4 && text.StartsWith("<I> ", StringComparison.Ordinal))
{
pre = "<I> ";
text = text.Substring(4);
}
if (text.Length > 3 && text.StartsWith("<I>", StringComparison.Ordinal))
{
pre = "<I>";
text = text.Substring(3);
}
if (text.Length > 2 && text.StartsWith('♪'))
{
pre = pre + "♪";
text = text.Substring(1);
}
if (text.Length > 2 && text.StartsWith(' '))
{
pre = pre + " ";
text = text.Substring(1);
}
if (text.Length > 2 && text.StartsWith('♫'))
{
pre = pre + "♫";
text = text.Substring(1);
}
if (text.Length > 2 && text.StartsWith(' '))
{
pre = pre + " ";
text = text.Substring(1);
}
char firstLetter = text[0];
string prevText = HtmlUtil.RemoveHtmlTags(arr[0]);
bool isPrevEndOfLine = Helper.IsPreviousTextEndOfParagraph(prevText);
if ((!text.StartsWith("www.", StringComparison.Ordinal) && !text.StartsWith("http:", StringComparison.Ordinal) && !text.StartsWith("https:", StringComparison.Ordinal)) &&
(char.IsLower(firstLetter) || Helper.IsTurkishLittleI(firstLetter, encoding, language)) &&
!prevText.EndsWith("...", StringComparison.Ordinal) &&
isPrevEndOfLine)
{
bool isMatchInKnowAbbreviations = language == "en" &&
(prevText.EndsWith(" o.r.", StringComparison.Ordinal) ||
prevText.EndsWith(" a.m.", StringComparison.Ordinal) ||
prevText.EndsWith(" p.m.", StringComparison.Ordinal));
if (!isMatchInKnowAbbreviations)
{
if (Helper.IsTurkishLittleI(firstLetter, encoding, language))
text = pre + Helper.GetTurkishUppercaseLetter(firstLetter, encoding) + text.Substring(1);
else if (language == "en" && (text.StartsWith("l ", StringComparison.Ordinal) || text.StartsWith("l-I", StringComparison.Ordinal) || text.StartsWith("ls ") || text.StartsWith("lnterested") ||
text.StartsWith("lsn't ", StringComparison.Ordinal) || text.StartsWith("ldiot", StringComparison.Ordinal) || text.StartsWith("ln", StringComparison.Ordinal) || text.StartsWith("lm", StringComparison.Ordinal) ||
text.StartsWith("ls", StringComparison.Ordinal) || text.StartsWith("lt", StringComparison.Ordinal) || text.StartsWith("lf ", StringComparison.Ordinal) || text.StartsWith("lc", StringComparison.Ordinal) || text.StartsWith("l'm ", StringComparison.Ordinal)) || text.StartsWith("l am ", StringComparison.Ordinal)) // l > I
text = pre + "I" + text.Substring(1);
else
text = pre + char.ToUpper(firstLetter) + text.Substring(1);
p.Text = arr[0] + Environment.NewLine + text;
}
}
arr = p.Text.SplitToLines();
if ((arr[0].StartsWith('-') || arr[0].StartsWith("<i>-", StringComparison.Ordinal)) &&
(arr[1].StartsWith('-') || arr[1].StartsWith("<i>-", StringComparison.Ordinal)) &&
!arr[0].StartsWith("--", StringComparison.Ordinal) && !arr[0].StartsWith("<i>--", StringComparison.Ordinal) &&
!arr[1].StartsWith("--", StringComparison.Ordinal) && !arr[1].StartsWith("<i>--", StringComparison.Ordinal))
{
if (isPrevEndOfLine && arr[1].StartsWith("<i>- ", StringComparison.Ordinal) && arr[1].Length > 6)
{
p.Text = arr[0] + Environment.NewLine + "<i>- " + char.ToUpper(arr[1][5]) + arr[1].Remove(0, 6);
}
else if (isPrevEndOfLine && arr[1].StartsWith("- ", StringComparison.Ordinal) && arr[1].Length > 3)
{
p.Text = arr[0] + Environment.NewLine + "- " + char.ToUpper(arr[1][2]) + arr[1].Remove(0, 3);
}
arr = p.Text.SplitToLines();
prevText = " .";
if (prev != null && p.StartTime.TotalMilliseconds - 10000 < prev.EndTime.TotalMilliseconds)
prevText = HtmlUtil.RemoveHtmlTags(prev.Text);
bool isPrevLineEndOfLine = Helper.IsPreviousTextEndOfParagraph(prevText);
if (isPrevLineEndOfLine && arr[0].StartsWith("<i>- ", StringComparison.Ordinal) && arr[0].Length > 6)
{
p.Text = "<i>- " + char.ToUpper(arr[0][5]) + arr[0].Remove(0, 6) + Environment.NewLine + arr[1];
}
else if (isPrevLineEndOfLine && arr[0].StartsWith("- ", StringComparison.Ordinal) && arr[0].Length > 3)
{
p.Text = "- " + char.ToUpper(arr[0][2]) + arr[0].Remove(0, 3) + Environment.NewLine + arr[1];
}
}
}
}
if (p.Text != null && p.Text.Length > 4)
{
int len = 0;
int indexOfNewLine = p.Text.IndexOf(Environment.NewLine + " -", 1, StringComparison.Ordinal);
if (indexOfNewLine < 0)
{
indexOfNewLine = p.Text.IndexOf(Environment.NewLine + "- <i> ♪", 1, StringComparison.Ordinal);
len = "- <i> ♪".Length;
}
if (indexOfNewLine < 0)
{
indexOfNewLine = p.Text.IndexOf(Environment.NewLine + "-", 1, StringComparison.Ordinal);
len = "-".Length;
}
if (indexOfNewLine < 0)
{
indexOfNewLine = p.Text.IndexOf(Environment.NewLine + "<i>-", 1, StringComparison.Ordinal);
len = "<i>-".Length;
}
if (indexOfNewLine < 0)
{
indexOfNewLine = p.Text.IndexOf(Environment.NewLine + "<i> -", 1, StringComparison.Ordinal);
len = "<i> -".Length;
}
if (indexOfNewLine < 0)
{
indexOfNewLine = p.Text.IndexOf(Environment.NewLine + "♪ -", 1, StringComparison.Ordinal);
len = "♪ -".Length;
}
if (indexOfNewLine < 0)
{
indexOfNewLine = p.Text.IndexOf(Environment.NewLine + "♪ <i> -", 1, StringComparison.Ordinal);
len = "♪ <i> -".Length;
}
if (indexOfNewLine < 0)
{
indexOfNewLine = p.Text.IndexOf(Environment.NewLine + "♪ <i>-", 1, StringComparison.Ordinal);
len = "♪ <i>-".Length;
}
if (indexOfNewLine > 0)
{
string text = p.Text.Substring(indexOfNewLine + len);
var st = new StripableText(text);
if (st.StrippedText.Length > 0 && Helper.IsTurkishLittleI(st.StrippedText[0], encoding, language) && !st.Pre.EndsWith('[') && !st.Pre.Contains("..."))
{
text = st.Pre + Helper.GetTurkishUppercaseLetter(st.StrippedText[0], encoding) + st.StrippedText.Substring(1) + st.Post;
p.Text = p.Text.Remove(indexOfNewLine + len).Insert(indexOfNewLine + len, text);
}
else if (st.StrippedText.Length > 0 && st.StrippedText[0] != char.ToUpper(st.StrippedText[0]) && !st.Pre.EndsWith('[') && !st.Pre.Contains("..."))
{
text = st.Pre + char.ToUpper(st.StrippedText[0]) + st.StrippedText.Substring(1) + st.Post;
p.Text = p.Text.Remove(indexOfNewLine + len).Insert(indexOfNewLine + len, text);
}
}
}
return p.Text;
}
}
}

View File

@ -0,0 +1,92 @@
using System.Globalization;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixStartWithUppercaseLetterAfterPeriodInsideParagraph : IFixCommonError
{
private bool IsAbbreviation(string text, int index, IFixCallbacks callbacks)
{
if (text[index] != '.' && text[index] != '!' && text[index] != '?')
return false;
if (index - 3 > 0 && Utilities.AllLettersAndNumbers.Contains(text[index - 1]) && text[index - 2] == '.') // e.g: O.R.
return true;
string word = string.Empty;
int i = index - 1;
while (i >= 0 && Utilities.AllLetters.Contains(text[i]))
{
word = text[i] + word;
i--;
}
return callbacks.GetAbbreviations().Contains(word + ".");
}
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.StartWithUppercaseLetterAfterPeriodInsideParagraph;
int noOfFixes = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
string oldText = p.Text;
var st = new StripableText(p.Text);
if (p.Text.Length > 3)
{
string text = st.StrippedText.Replace(" ", " ");
int start = text.IndexOfAny(new[] { '.', '!', '?' });
while (start != -1 && start < text.Length)
{
if (start > 0 && char.IsDigit(text[start - 1]))
{
// ignore periods after a number
}
else if (start + 4 < text.Length && text[start + 1] == ' ')
{
if (!IsAbbreviation(text, start, callbacks))
{
var subText = new StripableText(text.Substring(start + 2));
if (subText.StrippedText.Length > 0 && Helper.IsTurkishLittleI(subText.StrippedText[0], callbacks.Encoding, callbacks.Language))
{
if (subText.StrippedText.Length > 1 && !(subText.Pre.Contains('\'') && subText.StrippedText.StartsWith('s')))
{
text = text.Substring(0, start + 2) + subText.Pre + Helper.GetTurkishUppercaseLetter(subText.StrippedText[0], callbacks.Encoding) + subText.StrippedText.Substring(1) + subText.Post;
if (callbacks.AllowFix(p, fixAction))
{
p.Text = st.Pre + text + st.Post;
}
}
}
else if (subText.StrippedText.Length > 0 && Configuration.Settings.General.UppercaseLetters.Contains(char.ToUpper(subText.StrippedText[0])))
{
if (subText.StrippedText.Length > 1 && !(subText.Pre.Contains('\'') && subText.StrippedText.StartsWith('s')))
{
text = text.Substring(0, start + 2) + subText.Pre + char.ToUpper(subText.StrippedText[0]) + subText.StrippedText.Substring(1) + subText.Post;
if (callbacks.AllowFix(p, fixAction))
{
p.Text = st.Pre + text + st.Post;
}
}
}
}
}
start += 4;
if (start < text.Length)
start = text.IndexOfAny(new[] { '.', '!', '?' }, start);
}
}
if (oldText != p.Text)
{
noOfFixes++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
callbacks.UpdateFixStatus(noOfFixes, language.StartWithUppercaseLetterAfterPeriodInsideParagraph, noOfFixes.ToString(CultureInfo.InvariantCulture));
}
}
}

View File

@ -0,0 +1,32 @@
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixTurkishAnsiToUnicode : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixTurkishAnsi;
int noOfFixes = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
string text = p.Text;
string oldText = text;
text = text.Replace('Ý', 'İ');
text = text.Replace('Ð', 'Ğ');
text = text.Replace('Þ', 'Ş');
text = text.Replace('ý', 'ı');
text = text.Replace('ð', 'ğ');
text = text.Replace('þ', 'ş');
if (oldText != text && callbacks.AllowFix(p, fixAction))
{
p.Text = text;
noOfFixes++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
callbacks.UpdateFixStatus(noOfFixes, language.FixCommonOcrErrors, language.FixTurkishAnsi);
}
}
}

View File

@ -51,11 +51,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
if (unneededPeriodsFixed > 0)
{
callbacks.AddToTotalFixes(unneededPeriodsFixed);
callbacks.LogStatus(language.RemoveUnneededPeriods, string.Format(language.XUnneededPeriodsRemoved, unneededPeriodsFixed));
}
callbacks.UpdateFixStatus(unneededPeriodsFixed, language.RemoveUnneededPeriods, string.Format(language.XUnneededPeriodsRemoved, unneededPeriodsFixed));
}
}
}

View File

@ -22,11 +22,7 @@
}
}
}
if (doubleSpaces > 0)
{
callbacks.AddToTotalFixes(doubleSpaces);
callbacks.LogStatus(language.RemoveUnneededSpaces, string.Format(language.XUnneededSpacesRemoved, doubleSpaces));
}
callbacks.UpdateFixStatus(doubleSpaces, language.RemoveUnneededSpaces, string.Format(language.XUnneededSpacesRemoved, doubleSpaces));
}
}
}

View File

@ -0,0 +1,142 @@
using System;
using System.Text.RegularExpressions;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class FixUppercaseIInsideWords : IFixCommonError
{
private static readonly Regex ReAfterLowercaseLetter = new Regex(@"[a-zæøåäöéùáàìéóúñüéíóúñü]I", RegexOptions.Compiled);
private static readonly Regex ReBeforeLowercaseLetter = new Regex(@"I[a-zæøåäöéùáàìéóúñüéíóúñü]", RegexOptions.Compiled);
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.FixUppercaseIInsideLowercaseWord;
int uppercaseIsInsideLowercaseWords = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
string oldText = p.Text;
Match match = ReAfterLowercaseLetter.Match(p.Text);
while (match.Success)
{
if (!(match.Index > 1 && p.Text.Substring(match.Index - 1, 2) == "Mc") // irish names, McDonalds etc.
&& p.Text[match.Index + 1] == 'I'
&& callbacks.AllowFix(p, fixAction))
{
p.Text = p.Text.Substring(0, match.Index + 1) + "l";
if (match.Index + 2 < oldText.Length)
p.Text += oldText.Substring(match.Index + 2);
uppercaseIsInsideLowercaseWords++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
match = match.NextMatch();
}
var st = new StripableText(p.Text);
match = ReBeforeLowercaseLetter.Match(st.StrippedText);
while (match.Success)
{
string word = GetWholeWord(st.StrippedText, match.Index);
if (!callbacks.IsName(word))
{
if (callbacks.AllowFix(p, fixAction))
{
if (word.Equals("internal", StringComparison.OrdinalIgnoreCase) ||
word.Equals("island", StringComparison.OrdinalIgnoreCase) ||
word.Equals("islands", StringComparison.OrdinalIgnoreCase))
{
}
else if (match.Index == 0)
{ // first letter in paragraph
//too risky! - perhaps if periods is fixed at the same time... or too complicated!?
//if (isLineContinuation)
//{
// st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "l");
// p.Text = st.MergedString;
// uppercaseIsInsideLowercaseWords++;
// AddFixToListView(p, fixAction, oldText, p.Text);
//}
}
else
{
if (match.Index > 2 && st.StrippedText[match.Index - 1] == ' ')
{
if ((Utilities.AllLettersAndNumbers + @",").Contains(st.StrippedText[match.Index - 2])
&& match.Length >= 2 && Utilities.LowercaseVowels.Contains(char.ToLower(match.Value[1])))
{
st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "l");
p.Text = st.MergedString;
uppercaseIsInsideLowercaseWords++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
else if (match.Index > Environment.NewLine.Length + 1 && Environment.NewLine.Contains(st.StrippedText[match.Index - 1]))
{
if ((Utilities.AllLettersAndNumbers + @",").Contains(st.StrippedText[match.Index - Environment.NewLine.Length + 1])
&& match.Length >= 2 && Utilities.LowercaseVowels.Contains(match.Value[1]))
{
st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "l");
p.Text = st.MergedString;
uppercaseIsInsideLowercaseWords++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
else if (match.Index > 1 && ((st.StrippedText[match.Index - 1] == '\"') || (st.StrippedText[match.Index - 1] == '\'') ||
(st.StrippedText[match.Index - 1] == '>') || (st.StrippedText[match.Index - 1] == '-')))
{
}
else
{
var before = '\0';
var after = '\0';
if (match.Index > 0)
before = st.StrippedText[match.Index - 1];
if (match.Index < st.StrippedText.Length - 2)
after = st.StrippedText[match.Index + 1];
if (before != '\0' && char.IsUpper(before) && after != '\0' && char.IsLower(after) &&
!Utilities.LowercaseVowels.Contains(char.ToLower(before)) && !Utilities.LowercaseVowels.Contains(after))
{
st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "i");
p.Text = st.MergedString;
uppercaseIsInsideLowercaseWords++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
else if (@"‘’¡¿„“()[]♪'. @".Contains(before) && !Utilities.LowercaseVowels.Contains(char.ToLower(after)))
{
}
else
{
st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "l");
p.Text = st.MergedString;
uppercaseIsInsideLowercaseWords++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
}
}
}
match = match.NextMatch();
}
}
callbacks.UpdateFixStatus(uppercaseIsInsideLowercaseWords, language.FixUppercaseIInsindeLowercaseWords, language.XUppercaseIsFoundInsideLowercaseWords);
}
private static string GetWholeWord(string text, int index)
{
int start = index;
while (start > 0 && !(Environment.NewLine + @" ,.!?""'=()/-").Contains(text[start - 1]))
start--;
int end = index;
while (end + 1 < text.Length && !(Environment.NewLine + @" ,.!?""'=()/-").Contains(text[end + 1]))
end++;
return text.Substring(start, end - start + 1);
}
}
}

View File

@ -1,10 +1,42 @@
using System;
using System.Linq;
using System.Text;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public static class Helper
{
public static bool IsTurkishLittleI(char firstLetter, Encoding encoding, string language)
{
if (language != "tr")
{
return false;
}
return encoding.Equals(Encoding.UTF8)
? firstLetter == 'ı' || firstLetter == 'i'
: firstLetter == 'ý' || firstLetter == 'i';
}
public static char GetTurkishUppercaseLetter(char letter, Encoding encoding)
{
if (encoding.Equals(Encoding.UTF8))
{
if (letter == 'ı')
return 'I';
if (letter == 'i')
return 'İ';
}
else
{
if (letter == 'i')
return 'Ý';
if (letter == 'ý')
return 'I';
}
return letter;
}
public static string FixEllipsesStartHelper(string text)
{
if (string.IsNullOrEmpty(text) || text.Trim().Length < 4 || !(text.Contains("..", StringComparison.Ordinal) || text.Contains(". .", StringComparison.Ordinal)))

View File

@ -1,4 +1,6 @@
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using System.Collections.Generic;
using System.Text;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
@ -8,10 +10,13 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
void AddFixToListView(Paragraph p, string action, string before, string after);
void LogStatus(string sender, string message);
void LogStatus(string sender, string message, bool isImportant);
void AddToTotalFixes(int count);
void AddtoTotalErrors(int count);
void AddtoDeleteIndices(int index);
void UpdateFixStatus(int fixes, string message, string xMessage);
bool IsName(string candidate);
List<string> GetAbbreviations();
void AddToTotalErrors(int count);
void AddToDeleteIndices(int index);
SubtitleFormat Format { get; }
Encoding Encoding { get; }
string Language { get; }
}
}

View File

@ -0,0 +1,50 @@
using System;
using System.Text.RegularExpressions;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class RemoveSpaceBetweenNumbers : IFixCommonError
{
private static readonly Regex RemoveSpaceBetweenNumbersRegEx = new Regex(@"\d \d", RegexOptions.Compiled);
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.RemoveSpaceBetweenNumber;
int noOfFixes = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
string text = p.Text;
Match match = RemoveSpaceBetweenNumbersRegEx.Match(text);
int counter = 0;
while (match.Success && counter < 100 && text.Length > match.Index + 1)
{
string temp = text.Substring(match.Index + 2);
if (temp != "1/2" &&
!temp.StartsWith("1/2 ", StringComparison.Ordinal) &&
!temp.StartsWith("1/2.", StringComparison.Ordinal) &&
!temp.StartsWith("1/2!", StringComparison.Ordinal) &&
!temp.StartsWith("1/2?", StringComparison.Ordinal) &&
!temp.StartsWith("1/2<", StringComparison.Ordinal))
{
text = text.Remove(match.Index + 1, 1);
}
if (text.Length > match.Index + 1)
match = RemoveSpaceBetweenNumbersRegEx.Match(text, match.Index + 2);
counter++;
}
if (callbacks.AllowFix(p, fixAction) && p.Text != text)
{
string oldText = p.Text;
p.Text = text;
noOfFixes++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
callbacks.UpdateFixStatus(noOfFixes, language.FixCommonOcrErrors, string.Format(language.RemoveSpaceBetweenNumbersFixed, noOfFixes));
}
}
}

View File

@ -128,20 +128,42 @@
<Compile Include="FileUtil.cs" />
<Compile Include="FindReplaceDialogHelper.cs" />
<Compile Include="Forms\CheckForUpdatesHelper.cs" />
<Compile Include="Forms\FixCommonErrors\AddMissingQuotes.cs" />
<Compile Include="Forms\FixCommonErrors\EmptyFixCallback.cs" />
<Compile Include="Forms\FixCommonErrors\Fix3PlusLines.cs" />
<Compile Include="Forms\FixCommonErrors\FixAloneLowercaseIToUppercaseI.cs" />
<Compile Include="Forms\FixCommonErrors\FixDanishLetterI.cs" />
<Compile Include="Forms\FixCommonErrors\FixDialogsOnOneLine.cs" />
<Compile Include="Forms\FixCommonErrors\FixDoubleApostrophes.cs" />
<Compile Include="Forms\FixCommonErrors\FixDoubleDash.cs" />
<Compile Include="Forms\FixCommonErrors\FixDoubleGreaterThan.cs" />
<Compile Include="Forms\FixCommonErrors\FixEllipsesStart.cs" />
<Compile Include="Forms\FixCommonErrors\FixEmptyLines.cs" />
<Compile Include="Forms\FixCommonErrors\FixHyphensAdd.cs" />
<Compile Include="Forms\FixCommonErrors\FixHyphensRemove.cs" />
<Compile Include="Forms\FixCommonErrors\FixInvalidItalicTags.cs" />
<Compile Include="Forms\FixCommonErrors\FixLongDisplayTimes.cs" />
<Compile Include="Forms\FixCommonErrors\FixLongLines.cs" />
<Compile Include="Forms\FixCommonErrors\FixMissingOpenBracket.cs" />
<Compile Include="Forms\FixCommonErrors\FixMissingPeriodsAtEndOfLine.cs" />
<Compile Include="Forms\FixCommonErrors\FixMissingSpaces.cs" />
<Compile Include="Forms\FixCommonErrors\FixMusicNotation.cs" />
<Compile Include="Forms\FixCommonErrors\FixOverlappingDisplayTimes.cs" />
<Compile Include="Forms\FixCommonErrors\FixShortDisplayTimes.cs" />
<Compile Include="Forms\FixCommonErrors\FixShortLines.cs" />
<Compile Include="Forms\FixCommonErrors\FixShortLinesAll.cs" />
<Compile Include="Forms\FixCommonErrors\FixSpanishInvertedQuestionAndExclamationMarks.cs" />
<Compile Include="Forms\FixCommonErrors\FixStartWithUppercaseLetterAfterColon.cs" />
<Compile Include="Forms\FixCommonErrors\FixStartWithUppercaseLetterAfterParagraph.cs" />
<Compile Include="Forms\FixCommonErrors\FixStartWithUppercaseLetterAfterPeriodInsideParagraph.cs" />
<Compile Include="Forms\FixCommonErrors\FixTurkishAnsiToUnicode.cs" />
<Compile Include="Forms\FixCommonErrors\FixUnneededPeriods.cs" />
<Compile Include="Forms\FixCommonErrors\FixUnneededSpaces.cs" />
<Compile Include="Forms\FixCommonErrors\FixUppercaseIInsideWords.cs" />
<Compile Include="Forms\FixCommonErrors\Helper.cs" />
<Compile Include="Forms\FixCommonErrors\IFixCallbacks.cs" />
<Compile Include="Forms\FixCommonErrors\IFixCommonError.cs" />
<Compile Include="Forms\FixCommonErrors\RemoveSpaceBetweenNumbers.cs" />
<Compile Include="Forms\RemoveTextForHI.cs" />
<Compile Include="Forms\RemoveTextForHISettings.cs" />
<Compile Include="Forms\SplitLongLinesHelper.cs" />

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.Dictionaries;
using Nikse.SubtitleEdit.Core.Forms.FixCommonErrors;
using Nikse.SubtitleEdit.Forms;
using Nikse.SubtitleEdit.Logic.SpellCheck;
using System;
@ -416,8 +417,8 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
if (SpellCheckDictionaryName.StartsWith("en_", StringComparison.Ordinal) || _threeLetterIsoLanguageName == "eng")
{
string oldText = text;
text = FixCommonErrors.FixAloneLowercaseIToUppercaseLine(RegexAloneI, oldText, text, 'i');
text = FixCommonErrors.FixAloneLowercaseIToUppercaseLine(RegexAloneIasL, oldText, text, 'l');
text = FixAloneLowercaseIToUppercaseI.FixAloneLowercaseIToUppercaseLine(RegexAloneI, oldText, text, 'i');
text = FixAloneLowercaseIToUppercaseI.FixAloneLowercaseIToUppercaseLine(RegexAloneIasL, oldText, text, 'l');
}
else if (_threeLetterIsoLanguageName == "fra")
{

View File

@ -371,8 +371,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "This is line one!" + Environment.NewLine + "<i>Boy!</i>", "This is line one!" + Environment.NewLine + "<i>Boy!</i>");
target.FixMissingPeriodsAtEndOfLine();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "This is line one!" + Environment.NewLine + "<i>Boy!</i>");
new FixMissingPeriodsAtEndOfLine().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "This is line one!" + Environment.NewLine + "<i>Boy!</i>");
}
}
@ -383,8 +383,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "This is line one!" + Environment.NewLine + "<i>Boy</i>", "This is line one!" + Environment.NewLine + "<i>Boy!</i>");
target.FixMissingPeriodsAtEndOfLine();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "This is line one!" + Environment.NewLine + "<i>Boy.</i>");
new FixMissingPeriodsAtEndOfLine().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "This is line one!" + Environment.NewLine + "<i>Boy.</i>");
}
}
@ -395,8 +395,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "<i>This is line one!" + Environment.NewLine + "Boy</i>", "This is line one!" + Environment.NewLine + "<i>Boy!</i>");
target.FixMissingPeriodsAtEndOfLine();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "<i>This is line one!" + Environment.NewLine + "Boy.</i>");
new FixMissingPeriodsAtEndOfLine().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "<i>This is line one!" + Environment.NewLine + "Boy.</i>");
}
}
@ -407,8 +407,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "”... and gently down I laid her. ”");
target.FixMissingPeriodsAtEndOfLine();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "”... and gently down I laid her. ”");
new FixMissingPeriodsAtEndOfLine().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "”... and gently down I laid her. ”");
}
}
@ -423,8 +423,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "Hi Joe!" + Environment.NewLine + "- Hi Pete!");
target.FixHyphensAdd();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "- Hi Joe!" + Environment.NewLine + "- Hi Pete!");
new FixHyphensAdd().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "- Hi Joe!" + Environment.NewLine + "- Hi Pete!");
}
}
@ -435,8 +435,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "- Hi Joe!" + Environment.NewLine + "Hi Pete!");
target.FixHyphensAdd();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "- Hi Joe!" + Environment.NewLine + "- Hi Pete!");
new FixHyphensAdd().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "- Hi Joe!" + Environment.NewLine + "- Hi Pete!");
}
}
@ -447,8 +447,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "<i>- Hi Joe!" + Environment.NewLine + "Hi Pete!</i>");
target.FixHyphensAdd();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "<i>- Hi Joe!" + Environment.NewLine + "- Hi Pete!</i>");
new FixHyphensAdd().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "<i>- Hi Joe!" + Environment.NewLine + "- Hi Pete!</i>");
}
}
@ -459,8 +459,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "- Hi Joe!" + Environment.NewLine + "- Hi Pete!");
target.FixHyphensAdd();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "- Hi Joe!" + Environment.NewLine + "- Hi Pete!");
new FixHyphensAdd().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "- Hi Joe!" + Environment.NewLine + "- Hi Pete!");
}
}
@ -471,8 +471,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "- Hi!" + Environment.NewLine + "- Hi Pete!");
target.FixHyphensAdd();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "- Hi!" + Environment.NewLine + "- Hi Pete!");
new FixHyphensAdd().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "- Hi!" + Environment.NewLine + "- Hi Pete!");
}
}
@ -483,8 +483,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "Five-Both?" + Environment.NewLine + "- T... T... Ten...");
target.FixHyphensAdd();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "- Five-Both?" + Environment.NewLine + "- T... T... Ten...");
new FixHyphensAdd().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "- Five-Both?" + Environment.NewLine + "- T... T... Ten...");
}
}
@ -713,7 +713,7 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "Aφαίρεσαν ό,τι αντρικό είχες.");
new FixMissingSpaces().Fix(_subtitle, new EmptyFixCallback() { Language = "el" }); // Greek
new FixMissingSpaces().Fix(_subtitle, new EmptyFixCallback { Language = "el" }); // Greek
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "Aφαίρεσαν ό,τι αντρικό είχες.");
}
}
@ -868,8 +868,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "♪ you like to move it...");
target.FixStartWithUppercaseLetterAfterParagraph();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "♪ You like to move it...");
new FixStartWithUppercaseLetterAfterParagraph().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "♪ You like to move it...");
}
}
@ -877,20 +877,22 @@ namespace Test
[DeploymentItem("SubtitleEdit.exe")]
public void StartWithUppercaseAfterParagraphNormal1()
{
var prev = new Paragraph("Bye.", 0, 1000);
var p = new Paragraph("bye.", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "Bye.");
var s = new Subtitle();
s.Paragraphs.Add(new Paragraph("Bye.", 0, 1000));
s.Paragraphs.Add(new Paragraph("bye.", 1200, 5000));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(s.Paragraphs[1].Text, "Bye.");
}
[TestMethod]
[DeploymentItem("SubtitleEdit.exe")]
public void StartWithUppercaseAfterParagraphNormal2()
{
var prev = new Paragraph("Bye.", 0, 1000);
var p = new Paragraph("<i>bye.</i>", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "<i>Bye.</i>");
var s = new Subtitle();
s.Paragraphs.Add(new Paragraph("Bye.", 0, 1000));
s.Paragraphs.Add(new Paragraph("<i>bye.</i>", 1200, 5000));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(s.Paragraphs[1].Text, "<i>Bye.</i>");
}
[TestMethod]
@ -899,8 +901,11 @@ namespace Test
{
var prev = new Paragraph("<i>Bye.</i>", 0, 1000);
var p = new Paragraph("<i>bye.</i>", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "<i>Bye.</i>");
var s = new Subtitle();
s.Paragraphs.Add((prev));
s.Paragraphs.Add((p));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(p.Text, "<i>Bye.</i>");
}
[TestMethod]
@ -909,8 +914,11 @@ namespace Test
{
var prev = new Paragraph("Bye.", 0, 1000);
var p = new Paragraph("bye." + Environment.NewLine + "bye.", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "Bye." + Environment.NewLine + "Bye.");
var s = new Subtitle();
s.Paragraphs.Add((prev));
s.Paragraphs.Add((p));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(p.Text, "Bye." + Environment.NewLine + "Bye.");
}
[TestMethod]
@ -919,8 +927,11 @@ namespace Test
{
var prev = new Paragraph("Bye,", 0, 1000);
var p = new Paragraph("bye.", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "bye.");
var s = new Subtitle();
s.Paragraphs.Add((prev));
s.Paragraphs.Add((p));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(p.Text, "bye.");
}
[TestMethod]
@ -929,8 +940,11 @@ namespace Test
{
var prev = new Paragraph("Bye.", 0, 1000);
var p = new Paragraph("- Moss! Jesus Christ!" + Environment.NewLine + "- what is it?", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "- Moss! Jesus Christ!" + Environment.NewLine + "- What is it?");
var s = new Subtitle();
s.Paragraphs.Add((prev));
s.Paragraphs.Add((p));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(p.Text, "- Moss! Jesus Christ!" + Environment.NewLine + "- What is it?");
}
[TestMethod]
@ -939,8 +953,11 @@ namespace Test
{
var prev = new Paragraph("Bye.", 0, 1000);
var p = new Paragraph("<i>- Moss! Jesus Christ!" + Environment.NewLine + "- what is it?</i>", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "<i>- Moss! Jesus Christ!" + Environment.NewLine + "- What is it?</i>");
var s = new Subtitle();
s.Paragraphs.Add((prev));
s.Paragraphs.Add((p));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(p.Text, "<i>- Moss! Jesus Christ!" + Environment.NewLine + "- What is it?</i>");
}
[TestMethod]
@ -949,8 +966,11 @@ namespace Test
{
var prev = new Paragraph("Bye.", 0, 1000);
var p = new Paragraph("<i>- Moss! Jesus Christ!</i>" + Environment.NewLine + "<i>- what is it?</i>", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "<i>- Moss! Jesus Christ!</i>" + Environment.NewLine + "<i>- What is it?</i>");
var s = new Subtitle();
s.Paragraphs.Add((prev));
s.Paragraphs.Add((p));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(p.Text, "<i>- Moss! Jesus Christ!</i>" + Environment.NewLine + "<i>- What is it?</i>");
}
[TestMethod]
@ -959,8 +979,11 @@ namespace Test
{
var prev = new Paragraph("Bye.", 0, 1000);
var p = new Paragraph("<i>- moss! Jesus Christ!</i>" + Environment.NewLine + "<i>- what is it?</i>", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "<i>- Moss! Jesus Christ!</i>" + Environment.NewLine + "<i>- What is it?</i>");
var s = new Subtitle();
s.Paragraphs.Add((prev));
s.Paragraphs.Add((p));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(p.Text, "<i>- Moss! Jesus Christ!</i>" + Environment.NewLine + "<i>- What is it?</i>");
}
[TestMethod]
@ -969,8 +992,11 @@ namespace Test
{
var prev = new Paragraph("Bye", 0, 1000);
var p = new Paragraph("bye.", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "bye.");
var s = new Subtitle();
s.Paragraphs.Add((prev));
s.Paragraphs.Add((p));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(p.Text, "bye.");
}
[TestMethod]
@ -979,8 +1005,11 @@ namespace Test
{
var prev = new Paragraph("Bye -", 0, 1000);
var p = new Paragraph("- moss!", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "- moss!");
var s = new Subtitle();
s.Paragraphs.Add((prev));
s.Paragraphs.Add((p));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(p.Text, "- moss!");
}
[TestMethod]
@ -989,8 +1018,11 @@ namespace Test
{
var prev = new Paragraph("Bye -", 0, 1000);
var p = new Paragraph("- moss!" + Environment.NewLine + " - Bye.", 1200, 5000);
var fixedText = FixCommonErrors.FixStartWithUppercaseLetterAfterParagraph(p, prev, System.Text.Encoding.UTF8, "en");
Assert.AreEqual(fixedText, "- moss!" + Environment.NewLine + " - Bye.");
var s = new Subtitle();
s.Paragraphs.Add((prev));
s.Paragraphs.Add((p));
new FixStartWithUppercaseLetterAfterParagraph().Fix(s, new EmptyFixCallback());
Assert.AreEqual(p.Text, "- moss!" + Environment.NewLine + " - Bye.");
}
#endregion Start with uppercase after paragraph
@ -1004,8 +1036,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "Cómo estás?");
target.FixSpanishInvertedQuestionAndExclamationMarks();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "¿Cómo estás?");
new FixSpanishInvertedQuestionAndExclamationMarks().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "¿Cómo estás?");
}
}
@ -1016,8 +1048,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "Cómo estás!");
target.FixSpanishInvertedQuestionAndExclamationMarks();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "¡Cómo estás!");
new FixSpanishInvertedQuestionAndExclamationMarks().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "¡Cómo estás!");
}
}
@ -1028,8 +1060,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "¡¡PARA!!");
target.FixSpanishInvertedQuestionAndExclamationMarks();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "¡¡PARA!!");
new FixSpanishInvertedQuestionAndExclamationMarks().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "¡¡PARA!!");
}
}
@ -1040,8 +1072,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "¡¡¡PARA!!!");
target.FixSpanishInvertedQuestionAndExclamationMarks();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "¡¡¡PARA!!!");
new FixSpanishInvertedQuestionAndExclamationMarks().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "¡¡¡PARA!!!");
}
}
@ -1052,8 +1084,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "¿Cómo estás?!");
target.FixSpanishInvertedQuestionAndExclamationMarks();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "¡¿Cómo estás?!");
new FixSpanishInvertedQuestionAndExclamationMarks().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "¡¿Cómo estás?!");
}
}
@ -1064,8 +1096,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "<i>Chanchita, ¡¿copias?! Chanchita!!</i>");
target.FixSpanishInvertedQuestionAndExclamationMarks();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "<i>Chanchita, ¡¿copias?! ¡¡Chanchita!!</i>");
new FixSpanishInvertedQuestionAndExclamationMarks().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "<i>Chanchita, ¡¿copias?! ¡¡Chanchita!!</i>");
}
}
@ -1076,8 +1108,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "¡Cómo estás?");
target.FixSpanishInvertedQuestionAndExclamationMarks();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "¿¡Cómo estás!?");
new FixSpanishInvertedQuestionAndExclamationMarks().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "¿¡Cómo estás!?");
}
}
@ -1092,8 +1124,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "<i>- Mm-hmm.</i>");
target.FixHyphensRemove();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "<i>Mm-hmm.</i>");
new FixHyphensRemove().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "<i>Mm-hmm.</i>");
}
}
@ -1104,8 +1136,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "<font color='red'>- Mm-hmm.</font>");
target.FixHyphensRemove();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "<font color='red'>Mm-hmm.</font>");
new FixHyphensRemove().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "<font color='red'>Mm-hmm.</font>");
}
}
@ -1116,8 +1148,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "- Mm-hmm.");
target.FixHyphensRemove();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "Mm-hmm.");
new FixHyphensRemove().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "Mm-hmm.");
}
}
@ -1128,8 +1160,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "- I-I never thought of that.");
target.FixHyphensRemove();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "I-I never thought of that.");
new FixHyphensRemove().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "I-I never thought of that.");
}
}
@ -1140,8 +1172,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "- Uh-huh.");
target.FixHyphensRemove();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "Uh-huh.");
new FixHyphensRemove().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "Uh-huh.");
}
}
@ -1369,8 +1401,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "This is no troubIe!");
target.FixUppercaseIInsideWords();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "This is no trouble!");
new FixUppercaseIInsideWords().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "This is no trouble!");
}
}
@ -1381,8 +1413,8 @@ namespace Test
using (var target = GetFixCommonErrorsLib())
{
InitializeFixCommonErrorsLine(target, "- I'll ring her." + Environment.NewLine + "- ...In a lot of trouble.");
target.FixUppercaseIInsideWords();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "- I'll ring her." + Environment.NewLine + "- ...In a lot of trouble.");
new FixUppercaseIInsideWords().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "- I'll ring her." + Environment.NewLine + "- ...In a lot of trouble.");
}
}
@ -1432,8 +1464,8 @@ namespace Test
{
// <font color="#000000"> and <font>
InitializeFixCommonErrorsLine(target, "<font color=\"#000000\">-- Mm-hmm.</font>");
target.FixDoubleDash();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "<font color=\"#000000\">...Mm-hmm.</font>");
new FixDoubleDash().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "<font color=\"#000000\">...Mm-hmm.</font>");
}
}
@ -1445,8 +1477,8 @@ namespace Test
{
// <font color="#000000"> and <font>
InitializeFixCommonErrorsLine(target, "<b>Mm-hmm.</b>\r\n<font color=\"#000000\">-- foobar</font>");
target.FixDoubleDash();
Assert.AreEqual(target.Subtitle.Paragraphs[0].Text, "<b>Mm-hmm.</b>\r\n<font color=\"#000000\">...foobar</font>");
new FixDoubleDash().Fix(_subtitle, new EmptyFixCallback());
Assert.AreEqual(_subtitle.Paragraphs[0].Text, "<b>Mm-hmm.</b>\r\n<font color=\"#000000\">...foobar</font>");
}
}