Example #1
0
        /// <summary>
        /// Matches the two subtitles. The problem is that no two subtiles have the same timestamps or the same number of lines (they can be split, omitted, ...).
        /// This algotithm tries to find matching lines nontheless. The general algorithm works as following:
        ///
        /// Compare every "line1" in list1 with every "line2" in list2. Generate a score (between 0 and 1) how good they overlap. If the score is above a certain threshold, there
        /// will be an edge (as in graph theory) beween line1 and line2. There result is a bipartite graph that has many connected compontens. Every connected component is then a
        /// mached line.
        ///
        /// There is another step that removes matchings where two lines in same list overlap. See documentation of "RemoveOverlappings()" for more information.
        ///
        /// </summary>
        /// <returns>The subtitles.</returns>
        /// <param name="lines1">Lines1.</param>
        /// <param name="lines2">Lines2.</param>
        public static LinkedList <BiMatchedLines> MatchSubtitles(SubtitleMatcherCache cache)
        {
            List <ExtendedLineInfo> extendedLineInfos1 = (List <ExtendedLineInfo>)cache.ExtendedLineInfo1;
            List <ExtendedLineInfo> extendedLineInfos2 = (List <ExtendedLineInfo>)cache.ExtendedLineInfo2;

            // find matchings for every line in list1 to list2 and reverse
            FindMatching(extendedLineInfos1, extendedLineInfos2);

            RemoveOverlappings(extendedLineInfos1);
            RemoveOverlappings(extendedLineInfos2);

            var finalMappings = FindBidirectionalMapping(extendedLineInfos1, extendedLineInfos2);

            return(finalMappings);
        }
		/// <summary>
		/// Matches the two subtitles. The problem is that no two subtiles have the same timestamps or the same number of lines (they can be split, omitted, ...).
		/// This algotithm tries to find matching lines nontheless. The general algorithm works as following:
		///
		/// Compare every "line1" in list1 with every "line2" in list2. Generate a score (between 0 and 1) how good they overlap. If the score is above a certain threshold, there
		/// will be an edge (as in graph theory) beween line1 and line2. There result is a bipartite graph that has many connected compontens. Every connected component is then a
		/// mached line.
		///
		/// There is another step that removes matchings where two lines in same list overlap. See documentation of "RemoveOverlappings()" for more information.
		///
		/// </summary>
		/// <returns>The subtitles.</returns>
		/// <param name="lines1">Lines1.</param>
		/// <param name="lines2">Lines2.</param>
		public static LinkedList<BiMatchedLines> MatchSubtitles(SubtitleMatcherCache cache) {

			List<ExtendedLineInfo> extendedLineInfos1 = (List<ExtendedLineInfo>)cache.ExtendedLineInfo1;
			List<ExtendedLineInfo> extendedLineInfos2 = (List<ExtendedLineInfo>)cache.ExtendedLineInfo2;

			// find matchings for every line in list1 to list2 and reverse
			FindMatching (extendedLineInfos1, extendedLineInfos2);

			RemoveOverlappings (extendedLineInfos1);
			RemoveOverlappings (extendedLineInfos2);

			var finalMappings = FindBidirectionalMapping (extendedLineInfos1, extendedLineInfos2);

			return finalMappings;
		}