Esempio n. 1
0
        private void JoinBaseAndParallelVerses(ModuleVersePointer versesKey, ComparisonVersesInfo baseVerses, ComparisonVersesInfo parallelVerses,
                                               ModuleVersePointersComparisonTable bookVersePointersComparisonTables)
        {
            if (baseVerses.Count == 1)
            {
                if (parallelVerses.Count == 1 && baseVerses[0].PartIndex.GetValueOrDefault(-1) == parallelVerses[0].PartIndex.GetValueOrDefault(-1))
                {
                    var baseVerseToAdd     = (ModuleVersePointer)baseVerses[0].Clone();
                    var parallelVerseToAdd = (ModuleVersePointer)parallelVerses[0].Clone();
                    baseVerseToAdd.PartIndex     = null;
                    parallelVerseToAdd.PartIndex = null;
                    if (!bookVersePointersComparisonTables.ContainsKey(baseVerseToAdd))
                    {
                        bookVersePointersComparisonTables.Add(baseVerseToAdd, ComparisonVersesInfo.FromVersePointer(parallelVerseToAdd));
                    }
                }
                else
                {
                    bookVersePointersComparisonTables.Add(baseVerses[0], parallelVerses);
                }
            }
            else
            {
                var notApocryphaBaseVerses     = baseVerses.Where(v => !v.IsApocrypha);
                var notApocryphaParallelVerses = parallelVerses.Where(v => !v.IsApocrypha);

                bool isPartVersePointer = notApocryphaParallelVerses.Count() < notApocryphaBaseVerses.Count();


                int parallelVerseIndex = 0;
                List <ModuleVersePointer> prevParallelVerses = new List <ModuleVersePointer>();

                for (int baseVerseIndex = 0; baseVerseIndex < baseVerses.Count; baseVerseIndex++)
                {
                    var baseVerse     = baseVerses[baseVerseIndex];
                    var nextBaseVerse = baseVerseIndex < baseVerses.Count - 1 ? baseVerses[baseVerseIndex + 1] : null;

                    var getAllVerses = nextBaseVerse == null ? GetAllVersesType.All
                                                             : (nextBaseVerse.IsApocrypha != baseVerse.IsApocrypha
                                                                        ? GetAllVersesType.AllOfTheSameType
                                                                        : GetAllVersesType.One);

                    prevParallelVerses = GetParallelVersesList(baseVerse, parallelVerses, ref parallelVerseIndex, getAllVerses, isPartVersePointer, prevParallelVerses);

                    ComparisonVersesInfo parallelVersesInfo = new ComparisonVersesInfo(prevParallelVerses);
                    //parallelVersesInfo.Strict = parallelVerses.Strict;

                    bookVersePointersComparisonTables.Add(baseVerse, parallelVersesInfo);
                }
            }
        }
Esempio n. 2
0
        private void ProcessForBaseBookVerses(
            BibleTranslationDifferencesEx baseTranslationDifferencesEx,
            BibleTranslationDifferencesEx parallelTranslationDifferencesEx,
            ParallelBibleInfo result)
        {
            foreach (int bookIndex in baseTranslationDifferencesEx.BibleVersesDifferences.Keys)
            {
                var bookVersePointersComparisonTables = new ModuleVersePointersComparisonTable();
                result.Add(bookIndex, bookVersePointersComparisonTables);

                var baseBookVerses     = baseTranslationDifferencesEx.BibleVersesDifferences[bookIndex];
                var parallelBookVerses = parallelTranslationDifferencesEx.GetBibleVersesDifferences(bookIndex);

                foreach (var baseVerseKey in baseBookVerses.Keys)
                {
                    if (parallelBookVerses != null && parallelBookVerses.TryGetValue(baseVerseKey, out ComparisonVersesInfo parallelVerses))
                    {
                        var baseVerses = baseBookVerses[baseVerseKey];

                        JoinBaseAndParallelVerses(baseVerseKey, baseVerses, parallelVerses, bookVersePointersComparisonTables);
                    }
                    else
                    {
                        var baseVerses     = baseBookVerses[baseVerseKey];
                        int?versePartIndex = baseVerses.Count(v => !v.IsApocrypha && !v.IsEmpty) > 1 ? (int?)0 : null;
                        foreach (var baseVersePointer in baseVerses)
                        {
                            parallelVerses = ComparisonVersesInfo.FromVersePointer(
                                new ModuleVersePointer(baseVerseKey)
                            {
                                PartIndex         = versePartIndex.HasValue ? versePartIndex++ : null,
                                IsEmpty           = baseVersePointer.IsApocrypha || baseVerseKey.IsEmpty,
                                SkipCheck         = baseVerseKey.SkipCheck,
                                EmptyVerseContent = baseVerseKey.EmptyVerseContent
                            });

                            var key = (ModuleVersePointer)baseVersePointer.Clone();
                            key.PartIndex = null;  // нам просто здесь не важно - часть это стиха или нет.
                            bookVersePointersComparisonTables.Add(key, parallelVerses);
                        }
                    }
                }
            }
        }