/// <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); }
/// <summary> /// Returns the minimum time of all lines in BiMatchedLines. /// XXX: move this to BiMatchedLines? /// </summary> private double GetStartTime(SubtitleMatcher.BiMatchedLines biMatchedLines) { double startTime = 0; bool initialized = false; foreach (var lineList in biMatchedLines.listlines) { foreach (LineInfo line in lineList) { if (line.StartTime < startTime || !initialized) { startTime = line.StartTime; initialized = true; } } } return(startTime); }