Ejemplo n.º 1
0
 public AddReviewToDBResponse AddReviewNew([FromBody] AddReviewToDBParam param)
 {
     using (IWebsiteCrawler digikala = new DigikalaHelper())
     {
         var result = digikala.AddReviewToDB_NewMethod(param);
         return(new AddReviewToDBResponse {
             Success = result
         });
     }
 }
Ejemplo n.º 2
0
        public IActionResult AddLabel([FromBody] AddLabelParam model)
        {
            Dictionary <string, int> pol = new Dictionary <string, int>()
            {
                { "positive", 1 }, { "neutral", 0 }, { "negative", -1 }
            };

            if (model != null)
            {
                AddReviewToDBParam param = new AddReviewToDBParam();
                param.id     = model.idBson.ToString();
                param.tagger = model.Tagger;
                ReviewDTO review = new ReviewDTO();
                review._id        = "000";
                review.CreateDate = DateTime.Now;
                review.ProductID  = int.Parse(model.ProductId);
                review.rid        = int.Parse(model.ProductId);

                sentence sentence = new sentence();
                sentence.Text = model.Text;

                List <Opinion> Opinions = new List <Opinion>();
                if (model.AspectLabels.Count() > 0)
                {
                    Opinions.AddRange(model.AspectLabels.Select(x => new Opinion {
                        category = x.Category.ToUpper().Trim(), aspect = x.Aspect.ToUpper().Trim(), polarity = x.Polarity, polarityClass = pol[x.Polarity]
                    }).ToList());
                    sentence.Opinions = Opinions;
                }
                if (Opinions.Count < 1)
                {
                    sentence.OutOfScope = true;
                }
                review.sentences = new List <sentence>();
                review.sentences.Add(sentence);

                param.review = new ReviewDTO();
                param.review = review;
                using (IWebsiteCrawler digikala = new DigikalaHelper())
                {
                    var result = digikala.AddReviewToDB_NewMethod(param);
                    if (!result)
                    {
                        return(NoContent());
                    }
                }
                return(Json(new { Message = "ثبت شد" }));
            }
            else
            {
                return(NoContent());
            }
        }