コード例 #1
0
        public void CountLetters5HtmlFont()
        {
            var input = "<font color=\"red\"><i>Hal lo<i></font>";
            var res   = CalcFactory.MakeCalculator(nameof(CalcNoSpace)).CountCharacters(input);

            Assert.AreEqual("Hallo".Length, res);
        }
コード例 #2
0
        public void CountLetters6HtmlFontMultiLine()
        {
            var input = "<font color=\"red\"><i>Hal lo<i></font>" + Environment.NewLine + "<i>Bye!</i>";
            var res   = CalcFactory.MakeCalculator(nameof(CalcNoSpace)).CountCharacters(input);

            Assert.AreEqual("HalloBye!".Length, res);
        }
コード例 #3
0
        public void CountLetters4Ssa()
        {
            var input = "{\\an1}Hallo";
            var res   = CalcFactory.MakeCalculator(nameof(CalcAll)).CountCharacters(input);

            Assert.AreEqual("Hallo".Length, res);
        }
コード例 #4
0
        public void CountLetters4Html()
        {
            var input = "<i>Hallo</i>";
            var res   = CalcFactory.MakeCalculator(nameof(CalcAll)).CountCharacters(input);

            Assert.AreEqual("Hallo".Length, res);
        }
コード例 #5
0
        public void CountLetters3()
        {
            var input = " Hallo" + Environment.NewLine + "world!";
            var res   = CalcFactory.MakeCalculator(nameof(CalcAll)).CountCharacters(input);

            Assert.AreEqual(" Halloworld!".Length, res);
        }
コード例 #6
0
        public void CountLetters1()
        {
            var input = " Hallo  world! ";
            var res   = CalcFactory.MakeCalculator(nameof(CalcAll)).CountCharacters(input, false);

            Assert.AreEqual(" Hallo  world! ".Length, res);
        }
コード例 #7
0
        public void Check(Subtitle subtitle, NetflixQualityController controller)
        {
            ICalcLength calc = CalcFactory.MakeCalculator(nameof(CalcAll));
            var         charactersPerSecond = controller.CharactersPerSecond;
            var         comment             = "Maximum " + charactersPerSecond + " characters per second";

            foreach (var p in subtitle.Paragraphs)
            {
                var jp = new Paragraph(p);
                if (controller.Language == "ja")
                {
                    jp.Text = HtmlUtil.RemoveHtmlTags(jp.Text, true);
                    jp.Text = NetflixImsc11Japanese.RemoveTags(jp.Text);
                }

                if (controller.Language == "ko")
                {
                    calc = CalcFactory.MakeCalculator(nameof(CalcCjk));
                }

                var charactersPerSeconds = Utilities.GetCharactersPerSecond(jp, calc);
                if (charactersPerSeconds > charactersPerSecond && !p.StartTime.IsMaxTime)
                {
                    var fixedParagraph = new Paragraph(p, false);
                    while (Utilities.GetCharactersPerSecond(fixedParagraph) > charactersPerSecond)
                    {
                        fixedParagraph.EndTime.TotalMilliseconds++;
                    }

                    controller.AddRecord(p, fixedParagraph, comment, FormattableString.Invariant($"CPS={charactersPerSeconds:0.##}"));
                }
            }
        }
コード例 #8
0
 public static decimal CountCharacters(this string value)
 {
     return(CalcFactory.MakeCalculator(Configuration.Settings.General.CpsLineLengthStrategy).CountCharacters(value));
 }
コード例 #9
0
 /// <summary>
 /// Count characters excl. white spaces, ssa-tags, html-tags, control-characters, normal spaces and
 /// Arabic diacritics depending on parameter.
 /// </summary>
 public static int CountCharacters(this string value, string strategy)
 {
     return((int)Math.Round(CalcFactory.MakeCalculator(strategy).CountCharacters(value), MidpointRounding.AwayFromZero));
 }