Exemplo n.º 1
0
        internal bool IsPositiveReview(HttpRequestBase request, HttpResponseBase response, string review)
        {
            var newX       = TextClassificationProblemBuilder.CreateNode(review, vocabulary);
            var predictedY = model.Predict(newX);

            return(predictedY > 0 ? true : false);
        }
Exemplo n.º 2
0
        private RestuarantRecomandationByNLP()
        {
            string        dataFilePath = HttpContext.Current.Server.MapPath("~/App_Data/TrainingForIsPositiveAlgo.csv");
            var           dataTable    = DataAccess.DataTable.New.ReadCsv(dataFilePath);
            List <string> x            = dataTable.Rows.Select(row => row["Text"]).ToList();

            double[] y = dataTable.Rows.Select(row => double.Parse(row["IsPositive"]))
                         .ToArray();
            vocabulary = x.SelectMany(GetWords).Distinct().OrderBy(word => word).ToList();
            var       problemBuilder = new TextClassificationProblemBuilder();
            var       problem        = problemBuilder.CreateProblem(x, y, vocabulary.ToList());
            const int C = 1;

            model = new C_SVC(problem, KernelHelper.LinearKernel(), C);
            _predictionDictionary = new Dictionary <int, string> {
                { -1, "Bad" }, { 1, "Good" }
            };
        }