public override void PerformFunction(MySqlDataManipulator manipulator)
        {
            //Ensure that all KeywordPredictor models are loaded
            //If one is not, then a company requesting that model through its settings will cause an error
            if (!GlobalModelHelper.LoadOrTrainGlobalModels(ReflectionHelper.GetAllKeywordPredictors()))
            {
                throw new NullReferenceException("One or more global models failed to load. Server cannot start.");
            }
            DatabaseQueryProcessor processor = new DatabaseQueryProcessor(DatabaseQueryProcessorSettings.RetrieveCompanySettings(manipulator, CompanyId));

            List <RepairJobEntry> validatedData = manipulator.GetDataEntriesWhere(CompanyId, "id > 0", validated: true);
            List <string>         sentences;

            if (Flag.ToLower().Equals("complaint"))
            {
                //train model
                sentences = validatedData.Select(entry => entry.Complaint).ToList();
                if (!processor.TrainClusteringModels(manipulator, CompanyId, sentences, false))
                {
                    Console.WriteLine("Failed to train problem prediction models for company " + CompanyId);
                    return;
                }
                //register the complaint groups that the clusterer predicts with the repair job entry in the database
                foreach (RepairJobEntry entry in validatedData)
                {
                    string groups = JsonDataObjectUtil <List <int> > .ConvertObject(processor.PredictGroupsInJobData(entry, CompanyId, manipulator));

                    entry.ComplaintGroups = groups;
                    manipulator.UpdateDataEntryGroups(CompanyId, entry, complaint: true);
                }
            }
            Console.WriteLine("Trained clustering models for company " + CompanyId);
        }
        public static void TrainClusteringModel(MySqlDataManipulator manipulator, DatabaseQueryProcessor processor, int companyId, bool training = false)
        {
            List <RepairJobEntry> validatedData = manipulator.GetDataEntriesWhere(companyId, "id > 0", validated: true);
            List <string>         sentences;

            sentences = validatedData.Select(entry => entry.Complaint).ToList();
            if (!processor.TrainClusteringModels(manipulator, companyId, sentences, training))
            {
                Console.WriteLine("Failed to train problem prediction models for company " + companyId);
                return;
            }
            if (!training)
            {
                foreach (RepairJobEntry entry in validatedData)
                {
                    string groups = JsonDataObjectUtil <List <int> > .ConvertObject(processor.PredictGroupsInJobData(entry, companyId, manipulator));

                    entry.ComplaintGroups = groups;
                    manipulator.UpdateDataEntryGroups(companyId, entry, complaint: true);
                }
            }
        }