コード例 #1
0
        public void Check(Subtitle subtitle, NetflixQualityReportBuilder report)
        {
            foreach (Paragraph p in subtitle.Paragraphs)
            {
                // Line endings
                if (LineEndingSpaceBefore.IsMatch(p.Text))
                {
                    AddWhiteSpaceWarning(p, report, 1);
                }

                if (LineEndingSpaceAfter.IsMatch(p.Text))
                {
                    AddWhiteSpaceWarning(p, report, p.Text.Length);
                }

                // Spaces before punctuation
                foreach (Match m in SpacesBeforePunctuation.Matches(p.Text))
                {
                    AddWhiteSpaceWarning(p, report, m.Index + 1);
                }

                // 2+ consequent spaces
                foreach (Match m in TwoPlusConsequentSpaces.Matches(p.Text))
                {
                    AddWhiteSpaceWarning(p, report, m.Index);
                }
            }
        }
コード例 #2
0
        public void Check(Subtitle subtitle, NetflixQualityReportBuilder report)
        {
            // Load allowed glyphs
            int[]         allowedGlyphsArr = LoadNetflixGlyphs();
            HashSet <int> allowedGlyphsSet = new HashSet <int>(allowedGlyphsArr);

            // New line characters
            allowedGlyphsSet.Add(13);
            allowedGlyphsSet.Add(10);

            foreach (Paragraph paragraph in subtitle.Paragraphs)
            {
                for (int pos = 0, actualPos = 0; pos < paragraph.Text.Length;
                     pos += char.IsSurrogatePair(paragraph.Text, pos) ? 2 : 1, actualPos++)
                {
                    int curCodepoint = char.ConvertToUtf32(paragraph.Text, pos);

                    if (!allowedGlyphsSet.Contains(curCodepoint))
                    {
                        string timecode = paragraph.StartTime.ToHHMMSSFF();
                        string context  = NetflixQualityReportBuilder.StringContext(paragraph.Text, pos, 6);
                        string comment  = string.Format(Configuration.Settings.Language.NetflixQualityCheck.GlyphCheckReport,
                                                        string.Format("U+{0:X}", curCodepoint), actualPos);

                        report.AddRecord(timecode, context, comment);
                    }
                }
            }
        }
コード例 #3
0
        public void Check(Subtitle subtitle, NetflixQualityReportBuilder report)
        {
            foreach (Paragraph p in subtitle.Paragraphs)
            {
                // Line endings
                if (Regex.Match(p.Text, @"^( |\n|\r\n)[^\s]").Success)
                {
                    AddWhiteSpaceWarning(p, report, 1);
                }

                if (Regex.Match(p.Text, @"[^\s]( |\n|\r\n)$").Success)
                {
                    AddWhiteSpaceWarning(p, report, p.Text.Length);
                }

                // Spaces before punctuation
                foreach (Match m in Regex.Matches(p.Text, @"[^\s]( |\n|\r\n)[!?).,]"))
                {
                    AddWhiteSpaceWarning(p, report, m.Index + 1);
                }

                // 2+ consequent spaces
                foreach (Match m in Regex.Matches(p.Text, "( |\n|\r\n){2,}"))
                {
                    AddWhiteSpaceWarning(p, report, m.Index);
                }
            }
        }
コード例 #4
0
        private void AddWhiteSpaceWarning(Paragraph p, NetflixQualityReportBuilder report, int pos)
        {
            string timecode = p.StartTime.ToHHMMSSFF();
            string context  = NetflixQualityReportBuilder.StringContext(p.Text, pos, 6);
            string comment  = string.Format(Configuration.Settings.Language.NetflixQualityCheck.WhiteSpaceCheckReport, pos);

            report.AddRecord(timecode, context, comment);
        }