コード例 #1
0
        /// <summary>
        /// Returns a value between 0 and 1 how good the matching is.
        /// </summary>
        public double RateBiMatchedLines(SubtitleMatcher.BiMatchedLines biMatchedLines)
        {
            // [shared times between lines from list1 and list2] divided by [whole time]
            // ...because this value is between 0 and 0.5 we have to multiply it with 2

            // calculate "all time"
            double sharedTime      = 0;
            double allTimeSpanTime = 0;

            for (int listIndex = 0; listIndex < 2; listIndex++)
            {
                foreach (var currentLine in biMatchedLines.listlines[listIndex])
                {
                    allTimeSpanTime += UtilsCommon.GetTimeSpanLength(currentLine);
                }
            }

            // calculate "shared time"
            foreach (var lineInfoA in biMatchedLines.listlines[0])
            {
                foreach (var lineInfoB in biMatchedLines.listlines[1])
                {
                    sharedTime += UtilsCommon.OverlappingTimeSpan(lineInfoA, lineInfoB);
                }
            }

            return((sharedTime * 2) / allTimeSpanTime);
        }