private void MouseDoubleClick(object sender, MouseButtonEventArgs e) { PointLatLng clickpoint = new PointLatLng(); clickpoint = gmap.FromLocalToLatLng((int)Mouse.GetPosition(this).X, (int)Mouse.GetPosition(this).Y); Point point = new Point(clickpoint.Lat, clickpoint.Lng); Tweet tweet = new Tweet(); tweet.PointOnMap = point; foreach (var state in country.States) { foreach (var polygon in state.Polygons) { if (ExtraFuncs.IsInside(polygon, tweet)) { if (state.Tweets.Count == 0) { mostNegativeBlock.Text = "NaN"; mostPositiveBlock.Text = "NaN"; indexBlock.Text = state.Name.ToString(); } else { indexBlock.Text = state.Name.ToString(); mostNegativeBlock.Text = state.Tweets.Min(u => u.MoodWeight).ToString(); mostPositiveBlock.Text = state.Tweets.Max(u => u.MoodWeight).ToString(); } } } } }
public static double GetWeight(string message, Dictionary <char, List <Sentiment> > sentiments) { int maxNumberOfWordsInSentiment = 0; message = message.Trim(); string firstWordInPrase = String.Empty; List <Sentiment> sentimentsByFirstWord = new List <Sentiment>(); char[] delimiterChars = { '.', ',', '?', ':', '!', ';' }; string[] phrases = message.Split(delimiterChars); double fullWeigth = 0; foreach (var phrase in phrases) { string copyOfPhrase = phrase.Trim(); if (phrase == "") { continue; } while (copyOfPhrase.Length != 0) //FIX { firstWordInPrase = GetFirstWordInPhrase(copyOfPhrase); if (sentiments.ContainsKey(firstWordInPrase[0])) { var first = DateTime.Now; foreach (var sentiment in sentiments[firstWordInPrase[0]]) { if ((sentiment.Text + " ").StartsWith(firstWordInPrase + " ")) { sentimentsByFirstWord.Add(sentiment); if (ExtraFuncs.GetNumberOfWords(sentiment.Text) > maxNumberOfWordsInSentiment) { maxNumberOfWordsInSentiment = ExtraFuncs.GetNumberOfWords(sentiment.Text); } } } var second = DateTime.Now; double lol = (second - first).TotalSeconds; } if (sentimentsByFirstWord.Count == 0) { copyOfPhrase = copyOfPhrase.Remove(0, firstWordInPrase.Length).Trim(); continue; } string temp = CutPhrase(copyOfPhrase, maxNumberOfWordsInSentiment); fullWeigth += GetWeightOfPartOfPhrase(ref temp, sentimentsByFirstWord, maxNumberOfWordsInSentiment); copyOfPhrase = copyOfPhrase.Remove(0, temp.Length).Trim(); sentimentsByFirstWord.Clear(); } } return(fullWeigth); }
public AnalyticsItem(string?userId = null, DateTime?timestamp = null, string?anonymousId = null, Dictionary <string, object> context = null, Dictionary <string, object> integrations = null) { if (userId == null && anonymousId == null) { throw new SegmentHelperException( $"You need either anonymous or user id to have a value when creating an identify item."); } this.userId = userId; this.context = context; this.integrations = integrations; if (timestamp != null) { this.timestamp = ExtraFuncs.DateToISO8601Format(timestamp); } this.anonymousId = anonymousId; }
static private double GetWeightOfPartOfPhrase(ref string part, List <Sentiment> sentiments, int num) { double weight = 0; while (true) { foreach (Sentiment s in sentiments) { if (ExtraFuncs.GetNumberOfWords(s.Text) == num && part.ToLower().Trim() == s.Text) { return(s.Value); } } if (part.LastIndexOf(' ') != -1) { part = part.Substring(0, part.LastIndexOf(' ')); num--; } else { break; } } return(weight); }
public async Task StartNewState() { tweets = TweetParser.Parse(Path); country = ExtraFuncs.GroupTweetsByStates(tweets, @"..\..\..\Data\States\states.json"); }