Beispiel #1
0
        public ActionResult CompareResults()
        {
            NaiveBayesSentimentAnalizator.Train();
            SVMSentimentAnalyzator.Train();

            DataHandler.ImportReviewData(1);

            var model = new List <MultipleSentimentAnalysisData>();

            foreach (ReviewData review in DataHandler.Reviews)
            {
                MultipleSentimentAnalysisData resultItem = new MultipleSentimentAnalysisData()
                {
                    ReviewText = review.reviewText, Grade = review.overall
                };
                var currentSentiment = LexiconSentimentAnalizator.AnalyzeReview(review);
                resultItem.LexiconSentimentEvaluation = currentSentiment.SentimentEvaluation;
                currentSentiment = NaiveBayesSentimentAnalizator.AnalyzeReview(review);
                resultItem.NaiveBayesSentimentEvaluation = currentSentiment.SentimentEvaluation;
                currentSentiment = SVMSentimentAnalyzator.AnalyzeReview(review);
                resultItem.SVMSentimentEvaluation = currentSentiment.SentimentEvaluation;

                model.Add(resultItem);
            }

            return(View(model));
        }
Beispiel #2
0
        public ActionResult AnalyzeAllNaively()
        {
            NaiveBayesSentimentAnalizator.Train();

            var    model = new List <SentimentAnalysisData>();
            double error = 0;

            DataHandler.ImportReviewData(1);

            foreach (ReviewData review in DataHandler.Reviews)
            {
                var currentSentiment = NaiveBayesSentimentAnalizator.AnalyzeReview(review);
                error += Math.Abs(review.overall - currentSentiment.SentimentEvaluation);
                model.Add(currentSentiment);
            }

            Console.WriteLine(error);
            ViewBag.Name = "Naive Bayes Classification";
            return(View("AnalyzeAllML", model));
        }