Ejemplo n.º 1
0
        public void MigrateWords()
        {
            int counter = 0;

            foreach (var oldWord in mOldDb.Words)
            {
                var newWord = new New.Word();
                newWord.Name = oldWord.Name.Trim();
                PartGenus partGenus;
                string    plural;
                ParseAndFillPartGenusAndPlural(oldWord.Id, oldWord.Part, out partGenus, out plural);
                newWord.PartGenus = (int)partGenus;
                newWord.Plural    = plural;
                mNewDb.Words.Add(newWord);

                counter++;
                if (counter == 25000)
                {
                    counter = 0;
                    mNewDb.SaveChanges();
                    mNewDb.Dispose();
                    mNewDb = new New.RuDeDictContext();
                    System.Console.WriteLine(oldWord.Id);
                }
            }
            mNewDb.SaveChanges();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");

            using (var db = new Model.New.RuDeDictContext())
            {
                NewDbFormat.DudenWordChecker translator = new NewDbFormat.DudenWordChecker(db);
                do
                {
                    Console.WriteLine("Enter word to translate");
                    string input = Console.ReadLine();
                    if (input == "q")
                    {
                        break;
                    }
                    translator.CheckWord(input);
                }while (true);
            }
        }
Ejemplo n.º 3
0
        public void MigrateWordCategories()
        {
            int fakeNewWordCategoryId = 0;

            int counter = 0;
            var oldWordCategoryQuery =
                from wc in mOldDb.WordCategories
                join w in mOldDb.Words on wc.IdWord equals w.Id
                select new { IdCategory = wc.IdCategory, IdWord = wc.IdWord, Part = w.Part, WordName = w.Name };

            foreach (var oldWordCategory in oldWordCategoryQuery)
            {
                string decryptedIdCategory = System.Text.Encoding.ASCII.GetString(mCipher.Decrypt(oldWordCategory.IdCategory));

                int oldParsedIdCategory = int.Parse(decryptedIdCategory);
                //SELECT c.id, cn.name from category c join categorynamen cn on c.nameid=cn.id where c.id=
                var oldCategoryQuery =
                    from c in mOldDb.Categories
                    where c.Id == oldParsedIdCategory
                    select new { Id = c.Id, CategoryNameId = c.NameId };

                if (oldCategoryQuery.Count() != 1)
                {
                    System.Console.WriteLine("Error: oldCategoryQuery.Count() != 1 " + oldParsedIdCategory + " " + oldWordCategory.IdCategory);
                }
                var oldCategory = oldCategoryQuery.First();

                var newWord = FindNewWord(oldWordCategory.IdWord, oldWordCategory.Part, oldWordCategory.WordName);

                var newWordCategory = new New.WordCategory();
                fakeNewWordCategoryId++;
                newWordCategory.IdCategory     = fakeNewWordCategoryId;
                newWordCategory.IdCategoryName = oldCategory.CategoryNameId;
                newWordCategory.IdWord         = newWord.IdWord;
                mNewDb.WordCategories.Add(newWordCategory);
                //mNewDb.SaveChanges();

                var oldCategoryWordQuery =
                    from c in mOldDb.CategoryWords
                    join w in mOldDb.Words on c.IdWord equals w.Id
                    where c.IdCategory == oldCategory.Id
                    select new { Definition = c.Definition, Description = c.Description, IdWord = w.Id, WordName = w.Name, Part = w.Part };


                foreach (var oldCategoryWord in oldCategoryWordQuery)
                {
                    var newTranslatedWord = FindNewWord(oldCategoryWord.IdWord, oldCategoryWord.Part, oldCategoryWord.WordName);

                    var newCategoryWord = new New.CategoryWord();
                    newCategoryWord.IdWord     = newTranslatedWord.IdWord;
                    newCategoryWord.IdCategory = newWordCategory.IdCategory;

                    string oldCategoryWordDefinition = oldCategoryWord.Definition.Trim();
                    if (oldCategoryWordDefinition == "m" ||
                        oldCategoryWordDefinition == "f" ||
                        oldCategoryWordDefinition == "n")
                    {
                        newCategoryWord.Definition = string.Empty;
                    }
                    else
                    {
                        newCategoryWord.Definition = oldCategoryWordDefinition;
                    }
                    newCategoryWord.Description = oldCategoryWord.Description.Trim();

                    mNewDb.CategoryWords.Add(newCategoryWord);
                }
                counter++;
                if (counter == 5000)
                {
                    counter = 0;
                    mNewDb.SaveChanges();
                    if (newWordCategory.IdCategory != fakeNewWordCategoryId)
                    {
                        System.Console.WriteLine($"Error: fake word category id: {newWordCategory.IdCategory} != {fakeNewWordCategoryId}");
                    }
                    mNewDb.Dispose();
                    mNewDb = new New.RuDeDictContext();
                    System.Console.WriteLine(oldParsedIdCategory);
                }
            }
        }
Ejemplo n.º 4
0
 public ToNewFormatConverterRuDe(Old.RussianGermanDictionaryContext oldDb, New.RuDeDictContext newDb)
 {
     mOldDb = oldDb;
     mNewDb = newDb;
 }