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; if (p.Text.Length > 3 && callbacks.AllowFix(p, fixAction)) { var st = new StrippableText(p.Text); string text = st.StrippedText; int start = text.IndexOfAny(ExpectedChars); while (start > 0 && start < text.Length) { char charAtPosition = text[start]; // Allow fixing lowercase letter after recursive ??? or !!!. if (charAtPosition != '.') // Dot is not include 'cause I don't capitalize word after the ellipses (...), right? { while (start + 1 < text.Length && text[start + 1] == charAtPosition) { start++; } } // Try to reach the last dot if char at *start is '.'. if (charAtPosition == '.') { while (start + 1 < text.Length && text[start + 1] == '.') { start++; } } if ((start + 3 < text.Length) && (text[start + 1] == ' ') && !IsAbbreviation(text, start, callbacks)) { var textBefore = text.Substring(0, start + 1); var subText = new StrippableText(text.Substring(start + 2)); text = text.Substring(0, start + 2) + subText.CombineWithPrePost(ToUpperFirstLetter(textBefore, subText.StrippedText, callbacks)); } start += 3; if (start < text.Length) { start = text.IndexOfAny(ExpectedChars, start); } } text = st.CombineWithPrePost(text); if (oldText != text) { p.Text = text; noOfFixes++; callbacks.AddFixToListView(p, fixAction, oldText, p.Text); } } } callbacks.UpdateFixStatus(noOfFixes, language.StartWithUppercaseLetterAfterPeriodInsideParagraph, noOfFixes.ToString(CultureInfo.InvariantCulture)); }
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; if (p.Text.Length > 3 && callbacks.AllowFix(p, fixAction)) { var st = new StrippableText(p.Text); string text = st.StrippedText; int start = text.IndexOfAny(ExpectedChars); while (start > 0 && start < text.Length) { char charAtPosition = text[start]; // Allow fixing lowercase letter after recursive ??? or !!!. if (charAtPosition != '.') // Dot is not include 'cause I don't capitalize word after the ellipses (...), right? { while (start + 1 < text.Length && text[start + 1] == charAtPosition) { start++; } } if ((start + 3 < text.Length) && (text[start + 1] == ' ') && !IsAbbreviation(text, start, callbacks)) { var subText = new StrippableText(text.Substring(start + 2)); text = text.Substring(0, start + 2) + subText.CombineWithPrePost(ToUpperFirstLetter(subText.StrippedText, callbacks)); } // Try to reach the last dot if char at *start is '.'. if (charAtPosition == '.') { while (start + 1 < text.Length && text[start + 1] == '.') { start++; } } start += 3; if (start < text.Length) start = text.IndexOfAny(ExpectedChars, start); } text = st.CombineWithPrePost(text); if (oldText != text) { p.Text = text; noOfFixes++; callbacks.AddFixToListView(p, fixAction, oldText, p.Text); } } } callbacks.UpdateFixStatus(noOfFixes, language.StartWithUppercaseLetterAfterPeriodInsideParagraph, noOfFixes.ToString(CultureInfo.InvariantCulture)); }
public void Fix(Subtitle subtitle, IFixCallbacks callbacks) { 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; if (p.Text.Length > 3 && callbacks.AllowFix(p, fixAction)) { var st = new StrippableText(p.Text); string text = st.StrippedText; int start = text.IndexOfAny(ExpectedChars); while (start > 0 && start < text.Length) { char charAtPosition = text[start]; // Allow fixing lowercase letter after recursive ??? or !!!. if (charAtPosition != '.') // Dot is not include 'cause I don't capitalize word after the ellipses (...), right? { while (start + 1 < text.Length && text[start + 1] == charAtPosition) { start++; } } // Try to reach the last dot if char at *start is '.'. if (charAtPosition == '.') { while (start + 1 < text.Length && text[start + 1] == '.') { start++; } } if (start + 3 < text.Length && (text[start + 1] == ' ') && !IsAbbreviation(text, start, callbacks)) { var textBefore = text.Substring(0, start + 1); var subText = new StrippableText(text.Substring(start + 2)); text = text.Substring(0, start + 2) + subText.CombineWithPrePost(ToUpperFirstLetter(textBefore, subText.StrippedText, callbacks)); } start += 3; if (start < text.Length) { start = text.IndexOfAny(ExpectedChars, start); } } text = st.CombineWithPrePost(text); if (oldText != text) { p.Text = text; noOfFixes++; var isChecked = true; if (callbacks.Language == "bg" && text.Contains("г. ")) { // Bulgarian have "г." after years but the sentence continues with lowercase var regex = new Regex(@"\d г\. \p{L}"); var t1 = regex.Replace(oldText, string.Empty); var t2 = regex.Replace(text, string.Empty); isChecked = t1 != t2; } callbacks.AddFixToListView(p, fixAction, oldText, p.Text, isChecked); } } } callbacks.UpdateFixStatus(noOfFixes, Language.StartWithUppercaseLetterAfterPeriodInsideParagraph); }