Ejemplo n.º 1
0
        public void ParseMappingLine_CompareBaseToCustomized()
        {
            Versification vers2 = ScrVersReflectionHelper.CreateClonedVers(versification.VersInfo,
                                                                           versification.Name + "-monkey");
            ScrVers versification2 = new ScrVers(vers2);

            versification.ParseChapterVerseLine(
                "ACT 1:26 2:47 3:26 4:37 5:42 6:15 7:60 8:40 9:43 10:48 11:30 12:25 13:52 14:28 15:41 16:40 17:34 18:28 19:41 20:38 21:40 22:30 23:35 24:27 25:27 26:32 27:44 28:31");
            versification2.ParseChapterVerseLine(
                "ACT 1:26 2:47 3:26 4:37 5:42 6:15 7:60 8:40 9:43 10:48 11:30 12:25 13:52 14:28 15:41 16:40 17:34 18:28 19:41 20:38 21:40 22:30 23:35 24:27 25:27 26:32 27:44 28:31");

            versification2.ParseMappingLine("ACT 19:41 = ACT 19:40");
            versification.ParseMappingLine("ACT 19:41 = ACT 19:40");

            // Even tho we have both vers 40 and 41 mapped to the same verse, doing a conversion between the
            // two versification should not cause the original distinction to be lost if both versifications are
            // based on the same original versification.

            VerseRef vref = new VerseRef("ACT 19:40", versification);

            versification2.ChangeVersification(ref vref);
            Assert.AreEqual(new VerseRef("ACT 19:40", versification2), vref);

            vref = new VerseRef("ACT 19:41", versification);
            versification2.ChangeVersification(ref vref);
            Assert.AreEqual(new VerseRef("ACT 19:41", versification2), vref);
        }
Ejemplo n.º 2
0
        public void ParseMappingLine_SingleVerse()
        {
            versification.ParseMappingLine("NUM 17:1 = NUM 17:16");

            // Get mapping from "NUM 17:1 = NUM 17:16" in the versification
            VerseRef vref = new VerseRef(4, 17, 1, versification);

            ScrVers.Original.ChangeVersification(ref vref);
            Assert.AreEqual(new VerseRef(4, 17, 16, ScrVers.Original), vref);

            vref = new VerseRef(4, 17, 16, ScrVers.Original);
            versification.ChangeVersification(ref vref);
            Assert.AreEqual(new VerseRef(4, 17, 1, versification), vref);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Split blocks in the given book to match verse split locations
        /// </summary>
        /// <returns>A value indicating whether any splits were made</returns>
        private static bool MakesSplits(PortionScript blocksToSplit, int bookNum, ScrVers versification,
                                        List <VerseSplitLocation> verseSplitLocations, string descriptionOfProjectBeingSplit,
                                        string descriptionOfProjectUsedToDetermineSplitLocations, bool preventSplittingBlocksAlreadyMatchedToRefText = false)
        {
            if (!verseSplitLocations.Any())
            {
                return(false);
            }
            bool     splitsMade        = false;
            var      iSplit            = 0;
            VerseRef verseToSplitAfter = verseSplitLocations[iSplit];
            var      blocks            = blocksToSplit.GetScriptBlocks();

            for (int index = 0; index < blocks.Count; index++)
            {
                var block          = blocks[index];
                var initStartVerse = new VerseRef(bookNum, block.ChapterNumber, block.InitialStartVerseNumber,
                                                  versification);
                VerseRef initEndVerse;
                if (block.InitialEndVerseNumber != 0)
                {
                    initEndVerse = new VerseRef(bookNum, block.ChapterNumber, block.InitialEndVerseNumber,
                                                versification);
                }
                else
                {
                    initEndVerse = initStartVerse;
                }

                while (initEndVerse > verseToSplitAfter)
                {
                    if (iSplit == verseSplitLocations.Count - 1)
                    {
                        return(splitsMade);
                    }
                    verseToSplitAfter = verseSplitLocations[++iSplit];
                }

                var lastVerse = new VerseRef(bookNum, block.ChapterNumber, block.LastVerseNum, versification);
                if (lastVerse < verseToSplitAfter)
                {
                    continue;
                }

                if (initEndVerse.CompareTo(lastVerse) != 0 && lastVerse >= verseSplitLocations[iSplit].Before)
                {
                    bool invalidSplitLocation = false;
                    versification.ChangeVersification(verseToSplitAfter);
                    if (preventSplittingBlocksAlreadyMatchedToRefText && block.MatchesReferenceText)
                    {
                        invalidSplitLocation = blocksToSplit.GetVerseStringToUseForSplittingBlock(block, verseToSplitAfter.VerseNum) == null;
                    }
                    else if (blocksToSplit.TrySplitBlockAtEndOfVerse(block, verseToSplitAfter.VerseNum))
                    {
                        splitsMade = true;
                    }
                    else
                    {
                        invalidSplitLocation = true;
                    }

                    if (invalidSplitLocation)
                    {
#if DEBUG
                        if (!BlockContainsVerseEndInMiddleOfVerseBridge(block, verseToSplitAfter.VerseNum))
                        {
                            ErrorReport.NotifyUserOfProblem(
                                "Attempt to split {0} block to match breaks in the {1} text failed. Book: {2}; Chapter: {3}; Verse: {4}; Block: {5}",
                                descriptionOfProjectBeingSplit, descriptionOfProjectUsedToDetermineSplitLocations,
                                blocksToSplit.Id, block.ChapterNumber, verseToSplitAfter.VerseNum, block.GetText(true));
                        }
#endif
                        if (iSplit == verseSplitLocations.Count - 1)
                        {
                            break;
                        }
                        verseToSplitAfter = verseSplitLocations[++iSplit];
                        index--;
                    }
                }
            }
            return(splitsMade);
        }