示例#1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContextPool <SentimentWebContext>(
                options => options.UseSqlServer(Configuration.GetConnectionString("SentimentDb"),
                                                providerOptions => providerOptions.CommandTimeout(30)));

            services.AddScoped <ICustomerFBRepository, CustomerFBRepository>();
            services.AddScoped <IMLInputFBRepository, MLInputFBRepository>();
            services.AddScoped <IPredictionService, PredictionService>();
            services.AddSingleton <MLModelBuilder>();

            services.AddCors(options => {
                options.AddPolicy("policy",
                                  builder => {
                    builder.WithOrigins("http://localhost:4200")
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            services.AddControllers();

            if (!File.Exists(MLModelBuilder.GetAbsolutePath(SentimentML.Constants.ModelFilePath)))
            {
                var serviceProvider = services.BuildServiceProvider();
                var mlFabric        = serviceProvider.GetService <MLModelBuilder>();
                mlFabric.InitSQL();
            }

            if (!File.Exists(LanguageMLModelBuilder.GetAbsolutePath(Constants.ModelFilePath)))
            {
                LanguageMLModelBuilder.InitSQL();
            }
        }
示例#2
0
        public IActionResult RetrainTheMachine()
        {
            Task.Run(() => {
                _mlModelBuilder.InitSQL();

                LanguageMLModelBuilder.InitSQL();

                ApplicationLifetime.StopApplication();
            });

            return(Ok());
        }