Exemplo n.º 1
0
        public async void GO()
        {
            var s = new Sentimentize();
            await s.InitializeModelAsync();

            Dictionary <string, List <int> > answer = new Dictionary <string, List <int> >();

            foreach (ReviewViewModel rvm in DevItems2)
            {
                var n = rvm.Name;
                var c = rvm.Comment;
                s.txtInput = c;
                var useless_unused = await s.Evaluate();

                var output = s.txtOutput;   //this is "Positive" or "Negative" or "Unknown"

                if (!answer.ContainsKey(n))
                {
                    var newzerolist = new List <int>();
                    newzerolist.Add(0); newzerolist.Add(0);
                    answer.Add(n, newzerolist);
                }

                if (output == "Positive")
                {
                    answer[n][0] += 1;
                }
                else if (output == "Negative")
                {
                    answer[n][1] += 1;
                }
            }

            //answer is now fully populated, mapping names to pos/neg lists
            //now map dictionary to the list of SentimentViewModels
            _mainViewModel.UpdateSentimentDevItems(answer);

            //publish result on sentiments pop-up window
            eventAggregator.PublishOnUIThread(new OpenSentimentMessage());
        }
        public async void GO()
        {
            //list of reviews (devitems2)
            //then pass each review comment through Sentimentize (iteration) and
            //count pos and neg results for each review.name
            //map name, pos, neg to a Sentiment/SentimentViewModel for each review.name
            //and finally create devitems3 list based on these SentimentViewModels

            var s = new Sentimentize();
            await s.InitializeModelAsync();

            Console.WriteLine(s);

            Dictionary <string, List <int> > answer = new Dictionary <string, List <int> >();

            foreach (ReviewViewModel rvm in DevItems2)
            {
                var n = rvm.Name;
                var c = rvm.Comment;
                s.txtInput = c;
                var useless_unused = await s.Evaluate();

                var output = s.txtOutput;   //this is "Positive" or "Negative" or "Unknown"

                if (!answer.ContainsKey(n))
                {
                    var newzerolist = new List <int>();
                    newzerolist.Add(0); newzerolist.Add(0);
                    answer.Add(n, newzerolist);
                }

                if (output == "Positive")
                {
                    answer[n][0] += 1;
                }
                else if (output == "Negative")
                {
                    answer[n][1] += 1;
                }
            }

            //answer is now fully populated, mapping names to pos/neg lists
            //now map dictionary to the list of SentimentViewModels

            _mainViewModel.UpdateSentimentDevItems(answer);



            //Console.WriteLine(s.Evaluate("I love this nose soooo much!"));
            //s.txtInput = input;
            //Console.WriteLine("Entering Sentimentize.cs");
            //var useless = await s.Evaluate();
            ////Console.WriteLine(s.Evaluate("I love this nose soooo much!"));

            //txt.Wait();

            //FileHelper fh = new FileHelper();
            //fh.WriteTextFile("C:/Users/nionsong/Desktop/output_2.txt", txt);
            //Console.WriteLine("\nBack in Reviews Model.cs\n");
            //Console.WriteLine("THIS IS THE RESULT: " + s.txtOutput + "\n");
            //Console.WriteLine("\nEND RESULT\n" + s.txtOutput.GetType() + "\n^^is type of Result\n");

            eventAggregator.PublishOnUIThread(new OpenSentimentMessage());
        }