示例#1
0
        private void _BuildFromTRO(string path, UnitOfWork uow)
        {
            var conn  = GetConnection(path);
            var words = GetTroVerseInfos(conn);
            var c     = new GreekTransliterationController();

            uow.BeginTransaction();
            var strongs           = new XPQuery <StrongCode>(uow).ToList();
            var grammarCodes      = new XPQuery <GrammarCode>(uow).ToList();
            AncientDictionary dic = null;

            if (!new XPQuery <AncientDictionary>(uow).Any())
            {
                dic = new AncientDictionary(uow)
                {
                    Language = Language.Greek
                };
                dic.Save();
            }
            else
            {
                dic = new XPQuery <AncientDictionary>(uow).FirstOrDefault();
            }

            var exsistingWords = new List <TroVerseWord>();
            var exsistingItems = new XPQuery <AncientDictionaryItem>(uow);

            foreach (var item in exsistingItems)
            {
                exsistingWords.Add(new TroVerseWord()
                {
                    SourceWord = item.Word
                });
            }

            foreach (var word in words)
            {
                if (!exsistingWords.Where(x => x.SourceWord == word.SourceWord).Any())
                {
                    var item = new AncientDictionaryItem(uow)
                    {
                        Dictionary      = dic,
                        Word            = word.SourceWord,
                        Translation     = word.Translation,
                        Transliteration = c.TransliterateWord(word.SourceWord),
                        StrongCode      = strongs.Where(x => x.Lang == Language.Greek && x.Code == word.StrongCode).FirstOrDefault(),
                        GrammarCode     = grammarCodes.Where(x => x.GrammarCodeVariant1 == word.GrammarCode || x.GrammarCodeVariant2 == word.GrammarCode || x.GrammarCodeVariant3 == word.GrammarCode).FirstOrDefault()
                    };
                    item.Save();
                    exsistingWords.Add(new TroVerseWord()
                    {
                        SourceWord = word.SourceWord
                    });
                }
            }

            uow.CommitChanges();
        }
示例#2
0
        private void _BuildFromExisting(UnitOfWork uow)
        {
            uow.BeginTransaction();
            AncientDictionary dic = null;

            if (!new XPQuery <AncientDictionary>(uow).Any())
            {
                dic = new AncientDictionary(uow)
                {
                    Language = Language.Greek
                };
                dic.Save();
            }
            else
            {
                dic = new XPQuery <AncientDictionary>(uow).FirstOrDefault();
            }

            var c = new GreekTransliterationController();

            var exsistingWords = new List <TroVerseWord>();
            var exsistingItems = new XPQuery <AncientDictionaryItem>(uow);

            foreach (var item in exsistingItems)
            {
                exsistingWords.Add(new TroVerseWord()
                {
                    SourceWord = item.Word
                });
            }

            var words = new XPQuery <VerseWord>(uow).Where(x => x.Translation != null && x.Translation != "").ToList();

            foreach (var word in words)
            {
                var w = c.GetSourceWordWithoutBreathAndAccent(word.SourceWord.RemoveAny(".", ":", ",", ";", "·", "—", "-", ")", "(", "]", "[", "’", ";", "\""), out var isUpper).ToLower();
                if (!exsistingWords.Where(x => x.SourceWord == w).Any())
                {
                    var item = new AncientDictionaryItem(uow)
                    {
                        Dictionary      = dic,
                        Word            = w,
                        Translation     = word.Translation.RemoveAny(".", ":", ",", ";", "·", "—", "-", ")", "(", "]", "[", "’", ";", "\"" /*, "<n>", "</n>"*/),
                        Transliteration = word.Transliteration.RemoveAny(".", ":", ",", ";", "·", "—", "-", ")", "(", "]", "[", "’", ";", "\""),
                        StrongCode      = word.StrongCode,
                        GrammarCode     = word.GrammarCode
                    };
                    item.Save();
                    exsistingWords.Add(new TroVerseWord()
                    {
                        SourceWord = w
                    });
                }
            }
            uow.CommitChanges();
        }
示例#3
0
        private void BuildFromExisting(UnitOfWork uow)
        {
            uow.BeginTransaction();
            AncientDictionary dic = null;

            if (!new XPQuery <AncientDictionary>(uow).Any())
            {
                dic = new AncientDictionary(uow)
                {
                    Language = Language.Greek
                };
                dic.Save();
            }
            else
            {
                dic = new XPQuery <AncientDictionary>(uow).FirstOrDefault();
            }

            var strongs      = new XPQuery <StrongCode>(uow).ToList();
            var grammarCodes = new XPQuery <GrammarCode>(uow).ToList();

            var items = new List <AncientDictionaryItem>();

            var verseView = new XPView(uow, typeof(VerseWord))
            {
                CriteriaString = "Translation is not null AND Translation != ''"
            };

            verseView.Properties.Add(new ViewProperty("Oid", SortDirection.None, "[Oid]", false, true));
            verseView.Properties.Add(new ViewProperty("Translation", SortDirection.None, "[Translation]", false, true));
            verseView.Properties.Add(new ViewProperty("Transliteration", SortDirection.None, "[Transliteration]", false, true));
            verseView.Properties.Add(new ViewProperty("SourceWord", SortDirection.None, "[SourceWord]", false, true));
            verseView.Properties.Add(new ViewProperty("GrammarCodeId", SortDirection.None, "[GrammarCode.Oid]", false, true));
            verseView.Properties.Add(new ViewProperty("StrongCodeId", SortDirection.None, "[StrongCode.Oid]", false, true));

            var ancientDictionaryItemView = new XPView(uow, typeof(AncientDictionaryItem))
            {
                CriteriaString = "Translation is not null AND Translation != ''"
            };

            ancientDictionaryItemView.Properties.Add(new ViewProperty("Word", SortDirection.None, "[Word]", false, true));
            foreach (ViewRecord item in ancientDictionaryItemView)
            {
                items.Add(new AncientDictionaryItem(null)
                {
                    Word = item["Word"].ToString()
                });
            }

            foreach (ViewRecord item in verseView)
            {
                var sourceWord = item["SourceWord"].ToString().RemoveAny(".", ":", ",", ";", "·", "—", "-", ")", "(", "]", "[", "’", ";", "\"", "?").ToLower();
                if (!items.Where(x => x.Word.Equals(sourceWord)).Any())
                {
                    var translationText = item["Translation"].ToString().ToLower();
                    translationText = Regex.Replace(translationText, @"(?<c>\<n\>(\s+)?\[.+\](\s+)?\<\/n\>)", String.Empty, RegexOptions.IgnoreCase);
                    translationText = translationText.RemoveAny(".", ":", ",", ";", "·", "—", "-", ")", "(", "]", "[", "’", ";", "\"", "?").Trim();

                    if (translationText.IsNotNullOrEmpty())
                    {
                        var transliteration = item["Transliteration"].ToString().RemoveAny(".", ":", ",", ";", "·", "—", "-", ")", "(", "]", "[", "’", ";", "\"", "?").ToLower();

                        var dicItem = new AncientDictionaryItem(uow)
                        {
                            Word            = sourceWord,
                            Dictionary      = dic,
                            Translation     = translationText,
                            Transliteration = transliteration,
                            GrammarCode     = grammarCodes.Where(x => x.Oid == item["GrammarCodeId"].ToInt()).FirstOrDefault(),
                            StrongCode      = strongs.Where(x => x.Oid == item["StrongCodeId"].ToInt()).FirstOrDefault()
                        };

                        dicItem.Save();
                        items.Add(dicItem);
                    }
                }
            }

            uow.CommitChanges();
        }
示例#4
0
        private void BuildFromTRO(string path, UnitOfWork uow)
        {
            var conn  = GetConnection(path);
            var words = GetTroVerseInfos(conn);
            var c     = new GreekTransliterationController();

            uow.BeginTransaction();
            var strongs           = new XPQuery <StrongCode>(uow).ToList();
            var grammarCodes      = new XPQuery <GrammarCode>(uow).ToList();
            AncientDictionary dic = null;

            if (!new XPQuery <AncientDictionary>(uow).Any())
            {
                dic = new AncientDictionary(uow)
                {
                    Language = Language.Greek
                };
                dic.Save();
            }
            else
            {
                dic = new XPQuery <AncientDictionary>(uow).FirstOrDefault();
            }

            var ancientDictionaryItemView = new XPView(uow, typeof(AncientDictionaryItem))
            {
                CriteriaString = "Translation is not null AND Translation != ''"
            };

            ancientDictionaryItemView.Properties.Add(new ViewProperty("Word", SortDirection.None, "[Word]", false, true));

            var exsistingWords = new List <TroVerseWord>();

            foreach (ViewRecord item in ancientDictionaryItemView)
            {
                exsistingWords.Add(new TroVerseWord()
                {
                    SourceWord = item["Word"].ToString()
                });
            }

            foreach (var word in words)
            {
                if (!exsistingWords.Where(x => x.SourceWord == word.SourceWord).Any())
                {
                    var item = new AncientDictionaryItem(uow)
                    {
                        Dictionary      = dic,
                        Word            = word.SourceWord,
                        Translation     = word.Translation,
                        Transliteration = c.TransliterateWord(word.SourceWord),
                        StrongCode      = strongs.Where(x => x.Lang == Language.Greek && x.Code == word.StrongCode).FirstOrDefault(),
                        GrammarCode     = grammarCodes.Where(x => x.GrammarCodeVariant1 == word.GrammarCode || x.GrammarCodeVariant2 == word.GrammarCode || x.GrammarCodeVariant3 == word.GrammarCode).FirstOrDefault()
                    };
                    item.Save();
                    exsistingWords.Add(new TroVerseWord()
                    {
                        SourceWord = word.SourceWord
                    });
                }
            }

            uow.CommitChanges();
        }
        public void Build(UnitOfWork uow, string byzPath, string troPath)
        {
            var dic           = GetDictionary(uow);
            var byzConnection = GetConnection(byzPath);
            var troConnection = GetConnection(troPath);

            TroVerses = GetTroVerseInfos(troConnection);
            Strongs   = new XPQuery <StrongCode>(uow).Where(x => x.Lang == Language.Greek);
            ByzVerses = GetByzVerses(byzConnection);

#if DEBUG
            System.Diagnostics.Debug.WriteLine($"Budowanie modelu...");
#endif
            var info = GetDictionaryItemInfos();
            foreach (var item in info)
            {
                var word = new AncientDictionaryItem(uow)
                {
                    Dictionary      = this.Dictionary,
                    GrammarCode     = GetGrammarCode(uow, item.GrammarCode, item.GrammarCode2),
                    StrongCode      = GetStrongCode(item.StrongCode),
                    Word            = item.Text,
                    Translation     = item.Translation,
                    Transliteration = item.Transliterit
                };
                foreach (var reference in item.References)
                {
                    word.VersesReferences.Add(new VerseInfo(uow)
                    {
                        NumberOfBook    = reference.Book,
                        NumberOfChapter = reference.Chapter,
                        NumberOfVerse   = reference.Verse,
                        BaseBook        = new XPQuery <BookBase>(uow).Where(x => x.NumberOfBook == reference.Book).FirstOrDefault()
                    });
                }
                word.Save();

#if DEBUG
                System.Diagnostics.Debug.WriteLine($"{item.Text}");
#endif
            }


            //            foreach (var vi in ByzVerses) {
            //                var ti = GetTroVerseInfo(vi);
            //                if (ti.IsNotNull()) {
            //                    var verseInfo = new XPQuery<VerseInfo>(uow).Where(x => x.NumberOfBook == vi.Book && x.NumberOfChapter == vi.Chapter && x.NumberOfVerse == vi.Verse).FirstOrDefault();
            //                    if (verseInfo.IsNull()) {
            //                        verseInfo = new VerseInfo(uow) {
            //                            NumberOfBook = vi.Book,
            //                            NumberOfChapter = vi.Chapter,
            //                            NumberOfVerse = vi.Verse,
            //                            BaseBook = new XPQuery<BookBase>(uow).Where(x => x.NumberOfBook == vi.Book).FirstOrDefault()
            //                        };
            //                        verseInfo.Save();
            //                        uow.CommitChanges();
            //                        uow.ReloadChangedObjects();
            //                    }

            //                    foreach (var word in vi.Words) {
            //                        var tiWord = ti.Words.Where(x => x.StrongCode == word.StrongCode && x.GrammarCode != null && x.GrammarCode.Contains(word.GrammarCode)).FirstOrDefault();
            //                        if (tiWord.IsNotNull()) {
            //                            if (AddDictionaryItem(uow, word, tiWord, verseInfo)) {
            //#if DEBUG
            //                                System.Diagnostics.Debug.WriteLine($"Dodano słowo {word.Text} do słownika");
            //#endif
            //                            }
            //                        }
            //                    }
            //                }
            //            }

            System.Diagnostics.Debug.WriteLine($"Zapisywanie słownika");

            uow.CommitChanges();
            uow.ReloadChangedObjects();

            System.Diagnostics.Debug.WriteLine($"Zakończono budowanie słownika");


            /*
             * select
             * ancientdictionaryitem.Word as Słowo,
             * ancientdictionaryitem.Transliteration as Transliteracja,
             * ancientdictionaryitem.Translation as Tłumaczenie,
             * StrongCode.Code as [Kod Stronga],
             * StrongCode.Transliteration as [Transliteracja wg Stronga],
             * StrongCode.SourceWord as [Źródłosłów],
             * StrongCode.ShortDefinition	as [Definicja]
             * from ancientdictionaryitem, StrongCode
             * where 1=1
             * AND StrongCode.Lang = 2
             * AND ancientdictionaryitem.StrongCode = StrongCode.OID
             * order by ancientdictionaryitem.Word
             */
        }