Exemplo n.º 1
0
        public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
        {
            string fixAction    = string.Format(Language.FixHyphensInDialogs, Configuration.Settings.General.DialogStyle);
            int    iFixes       = 0;
            var    dialogHelper = new DialogSplitMerge
            {
                DialogStyle           = Configuration.Settings.General.DialogStyle,
                TwoLetterLanguageCode = callbacks.Language,
                ContinuationStyle     = Configuration.Settings.General.ContinuationStyle
            };

            for (int i = 0; i < subtitle.Paragraphs.Count; i++)
            {
                var p = subtitle.Paragraphs[i];
                if (callbacks.AllowFix(p, fixAction))
                {
                    string oldText = p.Text;
                    var    prev    = subtitle.GetParagraphOrDefault(i - 1);
                    string text    = dialogHelper.FixDashesAndSpaces(p.Text, p, prev);
                    if (text != oldText)
                    {
                        p.Text = text;
                        iFixes++;
                        callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
                    }
                }
            }
            callbacks.UpdateFixStatus(iFixes, fixAction);
        }
Exemplo n.º 2
0
        public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
        {
            var    language     = Configuration.Settings.Language.FixCommonErrors;
            string fixAction    = string.Format(language.FixHyphensInDialogs, Configuration.Settings.General.DialogStyle);
            int    iFixes       = 0;
            var    dialogHelper = new DialogSplitMerge {
                DialogStyle = Configuration.Settings.General.DialogStyle
            };

            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    = dialogHelper.FixDashesAndSpaces(p.Text);
                    if (text != oldText)
                    {
                        p.Text = text;
                        iFixes++;
                        callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
                    }
                }
            }
            callbacks.UpdateFixStatus(iFixes, fixAction, language.XHyphensInDialogsFixed);
        }
Exemplo n.º 3
0
        public void FixHyphensThreeLinesOneTwoDashSecondLineWithSpace()
        {
            var splitMerge = new DialogSplitMerge {
                DialogStyle = DialogType.DashSecondLineWithSpace
            };
            var result = splitMerge.FixDashesAndSpaces($"-What are you?{Environment.NewLine}-I'm a{ Environment.NewLine}one-in-a-generation artist.");

            Assert.AreEqual($"What are you?{Environment.NewLine}- I'm a{ Environment.NewLine}one-in-a-generation artist.", result);
        }
Exemplo n.º 4
0
        public void FixHyphensThreeLinesTwoOneNoSpace()
        {
            var splitMerge = new DialogSplitMerge {
                DialogStyle = DialogType.DashBothLinesWithoutSpace
            };
            var result = splitMerge.FixDashesAndSpaces($"- I'm a'{Environment.NewLine}one-in-a-generation artist.{Environment.NewLine}- Oh.");

            Assert.AreEqual($"-I'm a'{Environment.NewLine}one-in-a-generation artist.{Environment.NewLine}-Oh.", result);
        }
Exemplo n.º 5
0
        public void FixHyphensTwoLinesWithSpaceMissingSecondLine()
        {
            var splitMerge = new DialogSplitMerge {
                DialogStyle = DialogType.DashBothLinesWithSpace
            };
            var p      = new Paragraph($"- You can't talk either.{Environment.NewLine}That's what I said.", 4000, 7000);
            var result = splitMerge.FixDashesAndSpaces(p.Text, p, null);

            Assert.AreEqual($"- You can't talk either.{Environment.NewLine}- That's what I said.", result);
        }
        public void Check(Subtitle subtitle, NetflixQualityController controller)
        {
            if (controller.Language == "ja")
            {
                return;
            }

            var dialogHelper = new DialogSplitMerge {
                DialogStyle = controller.SpeakerStyle
            };
            string comment = "Dual Speakers: Use a hyphen without a space";

            if (controller.SpeakerStyle == DialogType.DashBothLinesWithSpace)
            {
                comment = "Dual Speakers: Use a hyphen with a space";
            }
            else if (controller.SpeakerStyle == DialogType.DashSecondLineWithSpace)
            {
                comment = "Dual Speakers: Use a hyphen with a space to denote the second speaker only";
            }
            else if (controller.SpeakerStyle == DialogType.DashSecondLineWithoutSpace)
            {
                comment = "Dual Speakers: Use a hyphen without a space to denote the second speaker only";
            }

            for (int i = 0; i < subtitle.Paragraphs.Count; i++)
            {
                var    p       = subtitle.Paragraphs[i];
                string oldText = p.Text;
                string newText = dialogHelper.FixDashesAndSpaces(p.Text, p, subtitle.GetParagraphOrDefault(i - 1));
                if (newText != oldText)
                {
                    var fixedParagraph = new Paragraph(p, false)
                    {
                        Text = newText
                    };
                    controller.AddRecord(p, fixedParagraph, comment);
                }
            }
        }