Exemplo n.º 1
0
        public ActionResult ShowRecom(RecoomendSuperclass.Percept percept)
        {
            c2T = new ConvertToText();
            TreeNode treeNode = c2T.RetrieveTree();

            accomodationSuper = new StudentAccomodationSuper();
            DFS dFS = new DFS();

            RecoomendSuperclass.Percept percepts = new RecoomendSuperclass.Percept();
            percepts.Incomegroup = percept.Incomegroup;
            percepts.area        = percept.area;


            List <string> recommendations = dFS.IterativeDeepeningSearch(treeNode, percepts, 3, 1);

            if (recommendations != null)
            {
                GetRecommendations(recommendations);
                //accomodationSuper.overalRecommendations = studentAccomodation;
                TempData["nullOverall"] = false;
            }
            else
            {
                TempData["nullOverall"] = true;
            }


            //List<string> recommendations_safety = dFS.IterativeDeepeningSearch(treeNode, percepts, 3, 2);
            //if (recommendations_safety != null)
            //{
            //    GetURecommendations(recommendations_safety);
            //    //accomodationSuper.basedOnSafety = studentAccomodation;
            //}
            //else
            //{

            //    TempData["nullSafety"] = true;
            //}

            List <string> recommendations_sentiment = dFS.IterativeDeepeningSearch(treeNode, percepts, 3, 3);

            if (recommendations_sentiment != null)
            {
                GetTRecommendations(recommendations_sentiment);
                // accomodationSuper.basedOnsentiment = studentAccomodation;

                TempData["nullSentiment"] = false;
            }
            else
            {
                TempData["nullSentiment"] = true;
            }

            if (accomodationSuper != null)
            {
                Session["RecommendationRating"] = accomodationSuper;
                return(RedirectToAction("ShowRecommendations", "Recommend"));
            }
            return(View());
        }
Exemplo n.º 2
0
        public int SaveRating(Rater rateings, StuAccomRatings studentAccomodation)
        {
            SentimentAnalysis sentiment = new SentimentAnalysis();

            if (ModelState.IsValid)
            {
                c2t      = new ConvertToText();
                treeNode = c2t.RetrieveTree();

                foreach (ChildNode node in treeNode.ChildNodes)
                {
                    if (node.data == studentAccomodation.IncomeGroup)
                    {
                        foreach (ChildNode area in node.Child)
                        {
                            if (area.data == studentAccomodation.location)
                            {
                                foreach (ChildNode acomodation in area.Child)
                                {
                                    if (studentAccomodation.Name == acomodation.data)
                                    {
                                        int val = acomodation.Id;
                                        if (val > 0)
                                        {
                                            acomodation.Id = (val + (rateings.safety + rateings.service)) / 2;
                                        }
                                        else
                                        {
                                            acomodation.Id = rateings.safety + rateings.service;
                                        }
                                        acomodation.safety = rateings.safety;

                                        acomodation.sentiment += sentiment.DeterminePolarity(studentAccomodation.review);

                                        var t = treeNode;


                                        c2t.SaveTree(treeNode);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                return(1);
            }

            return(-1);
        }