Ejemplo n.º 1
0
        public void LoadToDb()
        {
            var dbConnector = DbModelConnector.GetConnector();

            // dbConnector.ClearDb();
            using (var reader = new BinaryReader(Stream, Encoding.UTF8, true))
            {
                var header = ReadHeader(reader);
                var words  = header[0];
                var size   = header[1];


                WordVector vector;
                for (var i = 0; i < words; i++)
                {
                    vector = ReadVector(reader, words, size);
                    if (dbConnector.GetVector(vector.Word).Count() > 0)
                    {
                        dbConnector.AddVector(vector.Word, vector.Vector);
                    }
                    Console.WriteLine("Loading Model to Db: {0} % ", Math.Round(i / (float)words * 100, 4));
                    if ((i % 1000 == 0) || i == words - 1)
                    {
                        dbConnector.SaveChanges();
                    }
                }
                return;
            }
        }
Ejemplo n.º 2
0
 public DbModel()
 {
     connector = DbModelConnector.GetConnector();
 }