//
 // GET: /TestWorkflow?inputString=
 public ActionResult Index(string inputString)
 {
     SentimentAnalysis sa = new SentimentAnalysis();
     Debug.Write("teststs.");
     //IDictionary<string, object> results = WorkflowInvoker.Invoke(greeting);
        // ViewBag.Message = results["Result"].ToString();
     return View();
 }
Beispiel #2
0
        private void BtnShare_Click(object sender, RoutedEventArgs e)
        {
            TextRange tr = new TextRange(txtExperience.Document.ContentStart, txtExperience.Document.ContentEnd);

            String feedbackSentiment    = new SentimentAnalysis(tr.Text).getSentiment();
            double sentimentProbability = new SentimentAnalysis(tr.Text).getProbability();

            new ProjectController().InsertFeedback(tr.Text, project.ProjectID, employee.Employee_ID1, feedbackSentiment, sentimentProbability);
        }
Beispiel #3
0
        private void ManualOverride(SentimentAnalysis x)
        {
            Boolean warning = new[] { "I want to give up", "No-one would notice if I wasn’t here", "I hate myself" }
            .Any(s => x.Data.Contains(s, StringComparison.OrdinalIgnoreCase));

            if (warning)
            {
                x.Sentiment      = SentimentType.NEGATIVE;
                x.SentimentLevel = "high";
            }
        }
Beispiel #4
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);
        }
        private byte[] CreateRequest(string text)
        {
            logger.LogInformation("Creating sentiment score request");

            var sentimentRequest = new SentimentAnalysis <Request> {
                Documents = new List <Request> {
                    new Request {
                        Text = text
                    }
                }
            };
            var payload = JsonConvert.SerializeObject(sentimentRequest);

            return(Encoding.UTF8.GetBytes(payload));
        }
Beispiel #6
0
        public List <SentimentAnalysis> AnalyseConsumerFeedback()
        {
            var list    = new List <SentimentAnalysis>();
            var client  = new RestClient(sentimentAnalysisUri);
            var request = new RestRequest(Method.POST);

            request.AddHeader("Postman-Token", "d6b94fb3-8520-48cf-bff8-d983397eb7d9");
            request.AddHeader("Cache-Control", "no-cache");
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Accept", "application/json");
            request.AddHeader("Ocp-Apim-Subscription-Key", "72c321385eac4027b570a73b39c90361");
            var param = GetConsumerFeedBack();

            if (param != string.Empty)
            {
                var res = "{\r\n        \"documents\":  " + param + "  \r\n}";
                request.AddParameter("undefined", res, ParameterType.RequestBody);
                IRestResponse response       = client.Execute(request);
                var           jsonSerialiser = new JavaScriptSerializer();
                var           result         = jsonSerialiser.Deserialize <SentimentResponse>(response.Content).documents.ToList();

                if (result != null && result.Count > 0)
                {
                    foreach (var item in result)
                    {
                        var feedBackObj = db.tblFeedbacks.Where(x => x.ID == item.id).FirstOrDefault();
                        if (feedBackObj != null)
                        {
                            var consumerObj = db.tblConsumers.Where(x => x.ID == feedBackObj.Consumer_ID).FirstOrDefault();
                            if (consumerObj != null)
                            {
                                SentimentAnalysis analysisObj = new SentimentAnalysis()
                                {
                                    ID                     = item.id,
                                    ConsumerName           = consumerObj.ConsumerName,
                                    FeedBack               = feedBackObj.Feedback,
                                    Sentiment              = item.score,
                                    ConsumerProfilePicture = Convert.ToBase64String(feedBackObj.ConsumerProfilePicture, 0, feedBackObj.ConsumerProfilePicture.Length)
                                };
                                list.Add(analysisObj);
                            }
                        }
                    }
                }
            }

            return(list);
        }
Beispiel #7
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            // An example of object-level (i.e., multi-property) validation
            if (this.GenreId == 13 /* Indie */)
            {
                switch (SentimentAnalysis.GetSentiment(Title))
                {
                case SentimentAnalysis.SentimentResult.Positive:
                    yield return(new ValidationResult("Sounds too positive. Indie music requires more ambiguity."));

                    break;

                case SentimentAnalysis.SentimentResult.Negative:
                    yield return(new ValidationResult("Sounds too negative. Indie music requires more ambiguity."));

                    break;
                }
            }
        }
Beispiel #8
0
        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            TextRange tr = new TextRange(txtReview.Document.ContentStart, txtReview.Document.ContentEnd);

            /*
             * ComboBoxItem typeItem = (ComboBoxItem)cmbProject.SelectedItem;
             * int projectID = Convert.ToInt32(typeItem.Content);
             *
             * ComboBoxItem typeItem2 = (ComboBoxItem)cmbUser.SelectedItem;
             * int userID = Convert.ToInt32(typeItem2.Content);
             */
            int projectID = Convert.ToInt32(cmbProject.SelectedValue);
            int userID    = Convert.ToInt32(cmbUser.SelectedValue);


            Review review = new Review(projectID, userID, tr.Text.ToString(), employee.Employee_ID1);

            String sentiment = new SentimentAnalysis(tr.Text).getSentiment();

            new ReviewController().InsertReview(review, sentiment);
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            var               pusher  = new Pusher(pusherAppId, pusherAppKey, pusherAppSecret);
            TwitterAuth       auth    = new TwitterAuth();
            SentimentAnalysis analyze = new SentimentAnalysis();
            ParseString       parser  = new ParseString();

            var filteredStream = Stream.CreateFilteredStream();

            filteredStream.AddTrack("lol");
            filteredStream.MatchingTweetReceived += (sender, arg) =>
            {
                if (arg.Tweet.Coordinates != null)
                {
                    string  sentiment = analyze.Analyze(parser.Parse(arg.Tweet.Text));
                    MyTweet thisTweet = new TweetWithCoords(arg.Tweet.Text, sentiment, arg.Tweet.Coordinates.Latitude.ToString(), arg.Tweet.Coordinates.Longitude.ToString());
                    pusher.Trigger("tweetStream", "tweetEvent", new { message = thisTweet });
                    Console.WriteLine(arg.Tweet.Text);
                    Console.WriteLine("coords: " + arg.Tweet.Coordinates.Latitude + ", " + arg.Tweet.Coordinates.Longitude);
                    Console.WriteLine(sentiment);
                }
                else if (arg.Tweet.Place != null)
                {
                    string  sentiment = analyze.Analyze(parser.Parse(arg.Tweet.Text));
                    MyTweet thisTweet = new TweetWithPlace(arg.Tweet.Text, sentiment, arg.Tweet.Place.Name);
                    pusher.Trigger("tweetStream", "tweetEventWithPlace", new { message = thisTweet });
                    Console.WriteLine(arg.Tweet.Text);
                    Console.WriteLine("place: " + arg.Tweet.Place.Name);
                    Console.WriteLine(sentiment);
                }
            };
            while (true)
            {
                filteredStream.StartStreamMatchingAllConditions();
            }
        }
Beispiel #10
0
        private AverageSentiment ParseCommentThreadListResponse(CommentThreadListResponse commentThreadListResponse)
        {
            // Construct the empty parsed comment threads list
            AverageSentiment averageScore = new AverageSentiment();

            // Iterate over the comment thread list response and add each comment text
            foreach (CommentThread commentThread in commentThreadListResponse.Items)
            {
                var comment = new YoutubeComment();
                comment.AuthorName     = commentThread.Snippet.TopLevelComment.Snippet.AuthorDisplayName;
                comment.Content        = commentThread.Snippet.TopLevelComment.Snippet.TextDisplay;
                comment.SentimentScore = SentimentAnalysis.SelectComments(comment.Content);

                averageScore.CommentList.Add(comment);
            }

            // Set the average sentiment score
            averageScore.AverageSentimentScore = averageScore.CommentList.Average(c => c.SentimentScore);
            averageScore.VideoURL     = commentThreadListResponse.Items[0].Snippet.VideoId;
            averageScore.AnalysisDate = DateTime.Now;

            // Return the parsed comment threads list
            return(averageScore);
        }
        public SentimentAnalysisResponse Post(SentimentAnalysisRequest request)
        {
            if (request != null && request?.Sentiments.Count > 0)
            {
                List <SentimentData> sentimentDatas = new List <SentimentData>();
                foreach (string s in request.Sentiments)
                {
                    sentimentDatas.Add(new SentimentData()
                    {
                        SentimentText = s
                    });
                }

                SentimentAnalysis sentimentAnalysis = new SentimentAnalysis();
                MLContext         mlContext         = new MLContext();
                TrainTestData     splitDataView     = sentimentAnalysis.LoadData(mlContext);
                ITransformer      model             = sentimentAnalysis.BuildAndTrainModel(mlContext, splitDataView.TrainSet);
                sentimentAnalysis.Evaluate(mlContext, model, splitDataView.TestSet);
                //UseModelWithSingleItem(mlContext, model);
                return(sentimentAnalysis.PredictSentiments(mlContext, model, sentimentDatas));
            }

            return(null);
        }
Beispiel #12
0
 void OnEnable()
 {
     this.sentimentAnalysis = (SentimentAnalysis)target;
 }
Beispiel #13
0
        public override Task <Tuple <CustomErrors, Dictionary <string, CalendarEvent> > > BundleChangeUpdate(string EventId, EventName NewName, DateTimeOffset newStart, DateTimeOffset newEnd, int newSplitCount, string notes, bool forceRecalculation = false, SubCalendarEvent triggerSubEvent = null)
        {
            Task <TilerEvent> pendingNameAndMisc = null;
            //dynamic pendingNameAndMisc = null;
            bool useSubEvent = triggerSubEvent != null && triggerSubEvent.NameId.isNot_NullEmptyOrWhiteSpace() && triggerSubEvent.DataBlobId.isNot_NullEmptyOrWhiteSpace();

            if (useSubEvent)
            {
                if (this.myAccount.ScheduleLogControl.Database != null)
                {
                    pendingNameAndMisc = Task <TilerEvent> .Run(async() =>
                    {
                        SubCalendarEvent subRetValue = await this.myAccount.ScheduleLogControl.Database.SubEvents
                                                       .Include(eachSubEvent => eachSubEvent.DataBlob_EventDB)
                                                       .Include(eachSubEvent => eachSubEvent.Name)
                                                       .Include(eachSubEvent => eachSubEvent.SentimentAnalysis_DB)
                                                       .FirstAsync(eachSubEvent => eachSubEvent.Id == triggerSubEvent.Id).ConfigureAwait(false);
                        TilerEvent tileRetValue = (TilerEvent)subRetValue;
                        return(tileRetValue);
                    });
                }
            }
            else
            {
                var calEent = getCalendarEvent(EventId);
                if (calEent != null)
                {
                    if (this.myAccount.ScheduleLogControl.Database != null)
                    {
                        pendingNameAndMisc = Task <TilerEvent> .Run(async() =>
                        {
                            CalendarEvent calRetValue = await this.myAccount.ScheduleLogControl.Database.CalEvents
                                                        .Include(eachSubEvent => eachSubEvent.DataBlob_EventDB)
                                                        .Include(eachSubEvent => eachSubEvent.Name)
                                                        .FirstAsync(eachSubEvent => eachSubEvent.Id == calEent.Id).ConfigureAwait(false);
                            TilerEvent tileRetValue = (TilerEvent)calRetValue;
                            return(tileRetValue);
                        });
                    }
                }
            }

            var retValue = base.BundleChangeUpdate(EventId, NewName, newStart, newEnd, newSplitCount, notes, forceRecalculation, triggerSubEvent);


            TilerEvent tilerEvent = null;

            if (!useSubEvent)
            {
                tilerEvent = getCalendarEvent(EventId);
            }
            else
            {
                tilerEvent = triggerSubEvent;
            }

            if (pendingNameAndMisc != null)
            {
                pendingNameAndMisc.Wait();
                var pendingNameAndMiscResult = pendingNameAndMisc.Result;

                EventName         oldName           = pendingNameAndMiscResult.getName;
                MiscData          miscData          = pendingNameAndMiscResult.Notes;
                SentimentAnalysis sentimentAnalysis = pendingNameAndMiscResult.SentimentAnalysis_DB;
                bool isNameChange = NewName.NameValue != oldName?.NameValue;


                if (isNameChange)
                {
                    string emojiString = Task.Run(async() => await OpenAIService.Instance().getEmojis(NewName.NameValue)).GetAwaiter().GetResult();
                    if (sentimentAnalysis != null)
                    {
                        sentimentAnalysis.updateEmoji(emojiString);
                    }
                    else
                    {
                        sentimentAnalysis = new SentimentAnalysis();
                        tilerEvent.SentimentAnalysis_DB = sentimentAnalysis;
                        sentimentAnalysis.updateEmoji(emojiString);
                    }



                    tilerEvent.updateEventName(NewName.NameValue);
                }



                var note = miscData;
                if (note != null)
                {
                    note.UserNote = notes;
                }
            }

            return(retValue);
        }