Example #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This static method steps through all the ScrVerses of the given Current and Revision
		/// lists and determines which clusters of ScrVerses have overlapping verse ref ranges.
		/// </summary>
		/// <param name="scrVersesCurr">list of ScrVerses for the Current</param>
		/// <param name="scrVersesRev">list of ScrVerses for the Revision</param>
		/// <param name="cache">The database cache.</param>
		/// <returns>
		/// list of Cluster objects for the ScrVerses
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static List<Cluster> DetermineScrVerseOverlapClusters(List<ScrVerse> scrVersesCurr,
			List<ScrVerse> scrVersesRev, FdoCache cache)
		{
			int nScrVersesCurr = scrVersesCurr.Count;
			int nScrVersesRev = scrVersesRev.Count;

			// build the current and rev proxy lists, of OverlapInfo objects
			List<OverlapInfo> scrVerseProxyListCurr = new List<OverlapInfo>(nScrVersesCurr);
			List<OverlapInfo> scrVerseProxyListRev = new List<OverlapInfo>(nScrVersesRev);
			for (int iVerseRev = 0; iVerseRev < scrVersesRev.Count; iVerseRev++)
			{
				scrVerseProxyListRev.Add(new OverlapInfo(scrVersesRev[iVerseRev], true, iVerseRev));
				// When there is no content at the start of Scripture, it won't have a reference greater than 0.
				//Debug.Assert(BCVRef.GetChapterFromBcv(scrVersesRev[iVerseRev].StartRef) > 0); // catch test that forgot to set refs
			}
			for (int iVerseCurr = 0; iVerseCurr < scrVersesCurr.Count; iVerseCurr++)
			{
				scrVerseProxyListCurr.Add(new OverlapInfo(scrVersesCurr[iVerseCurr], false, iVerseCurr));
				// When there is no content at the start of Scripture, it won't have a reference greater than 0.
				//Debug.Assert(BCVRef.GetChapterFromBcv(scrVersesCurr[iVerseCurr].StartRef) > 0); // catch test that forgot to set refs
			}

			// Now build the list of section overlap clusters
			ClusterListHelper clh = new ClusterListHelper(cache);
			clh.DetermineAdjacentOverlapClusters(scrVerseProxyListCurr, scrVerseProxyListRev);

			// Simplify the complex clusters that have some correlated pairs
			// If the ScrVerse has the same number of words, but a couple are different, each
			// different word will count two times in the current alogrithm. However, if the words
			// are simply deleted or added, these words will only be counted once.
			clh.SimplifyComplexScrVerseClusters(scrVersesCurr, scrVersesRev, 0.75);

			// Simplifying clusters may have created new clusters with leading or trailing empty paras.
			// If so, pull these empty leading and/or trailing paragraphs into other clusters.
			clh.SimplifyLeadingTrailingEmptyParas(scrVersesCurr);

			// simplifying may create/delete clusters so we need to sort them
			clh.GenerateSortKeys(scrVersesCurr);
			clh.m_clusterList.Sort();

			return clh.m_clusterList;
		}
Example #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This static method steps through all the sections of the given Current and Revision
		/// books and determines which clusters of sections have overlapping verse ref ranges.
		/// </summary>
		/// <param name="bookCurr">the given current book</param>
		/// <param name="bookRev">the given book revision</param>
		/// <param name="cache">The database cache.</param>
		/// <param name="progressDlg">The progress dialog box.</param>
		/// <returns>
		/// list of Cluster objects for the sections of the books
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static List<Cluster> DetermineSectionOverlapClusters(IScrBook bookCurr,
			IScrBook bookRev, FdoCache cache, IProgress progressDlg)
		{
			int nSectionsCurr = bookCurr.SectionsOS.Count;
			int nSectionsRev = bookRev.SectionsOS.Count;

			// build the current and rev proxy lists, of OverlapInfo objects
			List<OverlapInfo> sectionProxyListCurr = new List<OverlapInfo>(nSectionsCurr);
			List<OverlapInfo> sectionProxyListRev = new List<OverlapInfo>(nSectionsRev);
			foreach (IScrSection section in bookRev.SectionsOS)
			{
				//REVIEW: should we skip intro sections in these lists??
				sectionProxyListRev.Add(new OverlapInfo(section, true));
				Debug.Assert(BCVRef.GetChapterFromBcv(section.VerseRefMin) > 0); // catch test that forgot to set section refs
				if (progressDlg != null)
					progressDlg.Step(1);
			}
			foreach (IScrSection section in bookCurr.SectionsOS)
			{
				sectionProxyListCurr.Add(new OverlapInfo(section, false));
				Debug.Assert(BCVRef.GetChapterFromBcv(section.VerseRefMin) > 0); // catch test that forgot to set section refs
				if (progressDlg != null)
					progressDlg.Step(1);
			}

			// Now build the list of section overlap clusters
			ClusterListHelper clh = new ClusterListHelper(cache);
			clh.DetermineOverlapClusters(sectionProxyListCurr, sectionProxyListRev);
			return clh.m_clusterList;
		}