mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-28 06:52:35 +01:00
Fix common errors -> Start with uppercase letter after colon/semicolon moved to seperate fix item (no longer in start with uppercase after paragraph/period)
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1253 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
87fd61a7e8
commit
ae2ee72299
@ -30,20 +30,21 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
const int IndexAddPeriodAfterParagraph = 13;
|
||||
const int IndexStartWithUppercaseLetterAfterParagraph = 14;
|
||||
const int IndexStartWithUppercaseLetterAfterPeriodInsideParagraph = 15;
|
||||
const int IndexAddMissingQuotes = 16;
|
||||
const int IndexFixHyphens = 17;
|
||||
const int IndexFix3PlusLines = 18;
|
||||
const int IndexFixDoubleDash = 19;
|
||||
const int IndexFixDoubleGreaterThan = 20;
|
||||
const int IndexFixEllipsesStart = 21;
|
||||
const int IndexFixMissingOpenBracket = 22;
|
||||
const int IndexFixOcrErrorsViaReplaceList = 23;
|
||||
const int IndexUppercaseIInsideLowercaseWord = 24;
|
||||
const int IndexAloneLowercaseIToUppercaseIEnglish = 25;
|
||||
const int IndexRemoveSpaceBetweenNumbers = 26;
|
||||
const int IndexDialogsOnOneLine = 27;
|
||||
const int IndexDanishLetterI = 28;
|
||||
const int IndexFixSpanishInvertedQuestionAndExclamationMarks = 29;
|
||||
const int IndexStartWithUppercaseLetterAfterColon = 16;
|
||||
const int IndexAddMissingQuotes = 17;
|
||||
const int IndexFixHyphens = 18;
|
||||
const int IndexFix3PlusLines = 19;
|
||||
const int IndexFixDoubleDash = 20;
|
||||
const int IndexFixDoubleGreaterThan = 21;
|
||||
const int IndexFixEllipsesStart = 22;
|
||||
const int IndexFixMissingOpenBracket = 23;
|
||||
const int IndexFixOcrErrorsViaReplaceList = 24;
|
||||
const int IndexUppercaseIInsideLowercaseWord = 25;
|
||||
const int IndexAloneLowercaseIToUppercaseIEnglish = 26;
|
||||
const int IndexRemoveSpaceBetweenNumbers = 27;
|
||||
const int IndexDialogsOnOneLine = 28;
|
||||
const int IndexDanishLetterI = 29;
|
||||
const int IndexFixSpanishInvertedQuestionAndExclamationMarks = 30;
|
||||
|
||||
int _danishLetterIIndex = -1;
|
||||
int _spanishInvertedQuestionAndExclamationMarksIndex = -1;
|
||||
@ -169,6 +170,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_fixActions.Add(new FixItem(_language.AddPeriods, string.Empty, delegate { FixMissingPeriodsAtEndOfLine(); }, ce.AddPeriodAfterParagraphTicked));
|
||||
_fixActions.Add(new FixItem(_language.StartWithUppercaseLetterAfterParagraph, string.Empty, delegate { FixStartWithUppercaseLetterAfterParagraph(); }, ce.StartWithUppercaseLetterAfterParagraphTicked));
|
||||
_fixActions.Add(new FixItem(_language.StartWithUppercaseLetterAfterPeriodInsideParagraph, string.Empty, delegate { FixStartWithUppercaseLetterAfterPeriodInsideParagraph(); }, ce.StartWithUppercaseLetterAfterPeriodInsideParagraphTicked));
|
||||
_fixActions.Add(new FixItem(_language.StartWithUppercaseLetterAfterColon, string.Empty, delegate { FixStartWithUppercaseLetterAfterColon(); }, ce.StartWithUppercaseLetterAfterColonTicked));
|
||||
_fixActions.Add(new FixItem(_language.AddMissingQuotes, _language.AddMissingQuotesExample, delegate { AddMissingQuotes(); }, ce.AddMissingQuotesTicked));
|
||||
_fixActions.Add(new FixItem(_language.FixHyphens, string.Empty, delegate { FixHyphens(); }, ce.FixHyphensTicked));
|
||||
_fixActions.Add(new FixItem(_language.Fix3PlusLines, string.Empty, delegate { Fix3PlusLines(); }, ce.Fix3PlusLinesTicked));
|
||||
@ -2075,9 +2077,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
!prevText.EndsWith("...") &&
|
||||
(prevText.EndsWith(".") ||
|
||||
prevText.EndsWith("!") ||
|
||||
prevText.EndsWith("?") ||
|
||||
prevText.EndsWith(":") ||
|
||||
prevText.EndsWith(";"));
|
||||
prevText.EndsWith("?"));
|
||||
|
||||
if (isPrevEndOfLine && prevText.Length > 5 && prevText.EndsWith(".") &&
|
||||
prevText[prevText.Length - 3] == '.' &&
|
||||
@ -2138,9 +2138,75 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
if (noOfFixes > 0)
|
||||
LogStatus(_language.StartWithUppercaseLetterAfterPeriodInsideParagraph, noOfFixes.ToString());
|
||||
|
||||
}
|
||||
|
||||
private void FixStartWithUppercaseLetterAfterColon()
|
||||
{
|
||||
string fixAction = _language.StartWithUppercaseLetterAfterColon;
|
||||
int noOfFixes = 0;
|
||||
for (int i = 0; i < _subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
Paragraph p = _subtitle.Paragraphs[i];
|
||||
Paragraph last = _subtitle.GetParagraphOrDefault(i - 1);
|
||||
string oldText = p.Text;
|
||||
int skipCount = 0;
|
||||
|
||||
if (last != null)
|
||||
{
|
||||
string lastText = Utilities.RemoveHtmlTags(last.Text);
|
||||
if (lastText.EndsWith(":") || lastText.EndsWith(";"))
|
||||
{
|
||||
var st = new StripableText(p.Text);
|
||||
if (st.StrippedText.Length > 0 && st.StrippedText[0].ToString() != st.StrippedText[0].ToString().ToUpper())
|
||||
p.Text = st.Pre + st.StrippedText[0].ToString().ToUpper() + st.StrippedText.Remove(0, 1) + st.Post;
|
||||
}
|
||||
}
|
||||
|
||||
if (oldText.Contains(":") || oldText.Contains(";"))
|
||||
{
|
||||
bool lastWasColon = false;
|
||||
for (int j = 0; j < p.Text.Length; j++)
|
||||
{
|
||||
string s = p.Text[j].ToString();
|
||||
if (s == ":" || s == ";")
|
||||
{
|
||||
lastWasColon = true;
|
||||
}
|
||||
else if (lastWasColon)
|
||||
{
|
||||
if (skipCount > 0)
|
||||
skipCount--;
|
||||
else if (p.Text.Substring(j).StartsWith("<i>"))
|
||||
skipCount = 2;
|
||||
else if (p.Text.Substring(j).StartsWith("<b>"))
|
||||
skipCount = 2;
|
||||
else if (p.Text.Substring(j).StartsWith("<u>"))
|
||||
skipCount = 2;
|
||||
else if (p.Text.Substring(j).StartsWith("<font ") && p.Text.Substring(j).Contains(">"))
|
||||
skipCount = p.Text.Substring(j).IndexOf(">") - p.Text.Substring(j).IndexOf("<font ");
|
||||
else if (s != s.ToUpper())
|
||||
{
|
||||
p.Text = p.Text.Remove(j, 1).Insert(j, s.ToUpper());
|
||||
lastWasColon = false;
|
||||
}
|
||||
else if (!(" " + Environment.NewLine).Contains(s))
|
||||
lastWasColon = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oldText != p.Text)
|
||||
{
|
||||
noOfFixes++;
|
||||
_totalFixes++;
|
||||
AddFixToListView(p, fixAction, oldText, p.Text);
|
||||
}
|
||||
}
|
||||
if (noOfFixes > 0)
|
||||
LogStatus(_language.StartWithUppercaseLetterAfterColon, noOfFixes.ToString());
|
||||
}
|
||||
|
||||
|
||||
private bool IsAbbreviation(string text, int index)
|
||||
{
|
||||
if (text[index] != '.' && text[index] != '!' && text[index] != '?')
|
||||
@ -3865,6 +3931,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ce.AddPeriodAfterParagraphTicked = listView1.Items[IndexAddPeriodAfterParagraph].Checked;
|
||||
ce.StartWithUppercaseLetterAfterParagraphTicked = listView1.Items[IndexStartWithUppercaseLetterAfterParagraph].Checked;
|
||||
ce.StartWithUppercaseLetterAfterPeriodInsideParagraphTicked = listView1.Items[IndexStartWithUppercaseLetterAfterPeriodInsideParagraph].Checked;
|
||||
ce.StartWithUppercaseLetterAfterColonTicked = listView1.Items[IndexStartWithUppercaseLetterAfterColon].Checked;
|
||||
ce.AddMissingQuotesTicked = listView1.Items[IndexAddMissingQuotes].Checked;
|
||||
ce.FixHyphensTicked = listView1.Items[IndexFixHyphens].Checked;
|
||||
ce.Fix3PlusLinesTicked = listView1.Items[IndexFix3PlusLines].Checked;
|
||||
|
@ -414,6 +414,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
AddPeriods = "Add period after lines where next line start with uppercase letter",
|
||||
StartWithUppercaseLetterAfterParagraph = "Start with uppercase letter after paragraph",
|
||||
StartWithUppercaseLetterAfterPeriodInsideParagraph = "Start with uppercase letter after period inside paragraph",
|
||||
StartWithUppercaseLetterAfterColon = "Start with uppercase letter after colon/semicolon",
|
||||
CommonOcrErrorsFixed = "Common OCR errors fixed (OcrReplaceList file used): {0}",
|
||||
RemoveSpaceBetweenNumber = "Remove space between numbers",
|
||||
FixDialogsOnOneLine = "Fix dialogs on one line",
|
||||
|
@ -355,6 +355,7 @@
|
||||
public string AddPeriods { get; set; }
|
||||
public string StartWithUppercaseLetterAfterParagraph { get; set; }
|
||||
public string StartWithUppercaseLetterAfterPeriodInsideParagraph { get; set; }
|
||||
public string StartWithUppercaseLetterAfterColon { get; set; }
|
||||
public string FixLowercaseIToUppercaseI { get; set; }
|
||||
public string FixCommonOcrErrors { get; set; }
|
||||
public string CommonOcrErrorsFixed { get; set; }
|
||||
|
@ -203,6 +203,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public bool AddPeriodAfterParagraphTicked { get; set; }
|
||||
public bool StartWithUppercaseLetterAfterParagraphTicked { get; set; }
|
||||
public bool StartWithUppercaseLetterAfterPeriodInsideParagraphTicked { get; set; }
|
||||
public bool StartWithUppercaseLetterAfterColonTicked { get; set; }
|
||||
public bool AloneLowercaseIToUppercaseIEnglishTicked { get; set; }
|
||||
public bool FixOcrErrorsViaReplaceListTicked { get; set; }
|
||||
public bool RemoveSpaceBetweenNumberTicked { get; set; }
|
||||
@ -232,6 +233,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
AddPeriodAfterParagraphTicked = false;
|
||||
StartWithUppercaseLetterAfterParagraphTicked = true;
|
||||
StartWithUppercaseLetterAfterPeriodInsideParagraphTicked = false;
|
||||
StartWithUppercaseLetterAfterColonTicked = false;
|
||||
AloneLowercaseIToUppercaseIEnglishTicked = false;
|
||||
DanishLetterITicked = false;
|
||||
FixDoubleDashTicked = true;
|
||||
@ -1233,6 +1235,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
subNode = node.SelectSingleNode("StartWithUppercaseLetterAfterPeriodInsideParagraphTicked");
|
||||
if (subNode != null)
|
||||
settings.CommonErrors.StartWithUppercaseLetterAfterPeriodInsideParagraphTicked = Convert.ToBoolean(subNode.InnerText);
|
||||
subNode = node.SelectSingleNode("StartWithUppercaseLetterAfterColonTicked");
|
||||
if (subNode != null)
|
||||
settings.CommonErrors.StartWithUppercaseLetterAfterColonTicked = Convert.ToBoolean(subNode.InnerText);
|
||||
subNode = node.SelectSingleNode("AloneLowercaseIToUppercaseIEnglishTicked");
|
||||
if (subNode != null)
|
||||
settings.CommonErrors.AloneLowercaseIToUppercaseIEnglishTicked = Convert.ToBoolean(subNode.InnerText);
|
||||
@ -1823,6 +1828,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
textWriter.WriteElementString("AddPeriodAfterParagraphTicked", settings.CommonErrors.AddPeriodAfterParagraphTicked.ToString());
|
||||
textWriter.WriteElementString("StartWithUppercaseLetterAfterParagraphTicked", settings.CommonErrors.StartWithUppercaseLetterAfterParagraphTicked.ToString());
|
||||
textWriter.WriteElementString("StartWithUppercaseLetterAfterPeriodInsideParagraphTicked", settings.CommonErrors.StartWithUppercaseLetterAfterPeriodInsideParagraphTicked.ToString());
|
||||
textWriter.WriteElementString("StartWithUppercaseLetterAfterColonTicked", settings.CommonErrors.StartWithUppercaseLetterAfterColonTicked.ToString());
|
||||
textWriter.WriteElementString("AloneLowercaseIToUppercaseIEnglishTicked", settings.CommonErrors.AloneLowercaseIToUppercaseIEnglishTicked.ToString());
|
||||
textWriter.WriteElementString("FixOcrErrorsViaReplaceListTicked", settings.CommonErrors.FixOcrErrorsViaReplaceListTicked.ToString());
|
||||
textWriter.WriteElementString("RemoveSpaceBetweenNumberTicked", settings.CommonErrors.RemoveSpaceBetweenNumberTicked.ToString());
|
||||
|
Loading…
Reference in New Issue
Block a user