Пример #1
0
        /// <summary>
        /// Adds a row to the list of Models  (in the ModelsDb) if none exists and returns an object of type ModelDatabase,
        /// representing the new model.  In the process creates a new db to hold the new model's data.  If thes db has already been created it simply opens a connection to it.
        /// </summary>
        /// <param name="sqlServer"></param>
        /// <param name="modelsDbName"></param>
        /// <param name="ldaConfig"></param>
        /// <returns></returns>
        private static ModelDatabase AddModelParametersToModelsDb(ModelsDb modelsDb, LDAConfig ldaConfig, string modelRepositoryPath, ref bool success)
        {
            var metrics = ExtractModelMetrics(ref ldaConfig, modelRepositoryPath);

            if (metrics == null)
            {
                return(null);
            }

            string modelDbName;
            int    modelId;

            try
            {
                StatusMessage.Write("Adding metrics to Db: " + ldaConfig.ExtrinsicMetricsProcessed);
                modelsDb.AddModel(ldaConfig, metrics, out modelDbName, out modelId);
                success = true;
            }
            catch (Exception e)
            {
                StatusMessage.Write("Could not add a record to the Topic models db:" + e.ToString());
                throw;
            }

            var model = new ModelDatabase("", modelsDb.serverName, modelDbName, false);

            if (model.Open())
            {
                //The database has already been created
            }

            return(model);
        }
Пример #2
0
 private static ModelsDb GetModelsDb(string sqlServer, string modelsDbName)
 {
     try
     {
         var metricDictionary = GetMetricsDictionary();
         var modelsDb         = new ModelsDb(sqlServer, modelsDbName, metricDictionary);
         modelsDb.Open();
         return(modelsDb);
     }
     catch (Exception e)
     {
         StatusMessage.Write("Could not add a record to the Topic models db:" + e.ToString());
         return(null);
     }
 }