private Word PickWord(TwitterProfile profile, Word previousWord) { var algorithm = _options.WordAlgorithms.PickAlgorithm(_random); Word word = null; switch (algorithm) { case AlgorithmType.Random: word = PickWordRandom(profile); break; case AlgorithmType.ByProbability: word = PickWordByProbability(profile); break; case AlgorithmType.ByProbabilityWithPrediction: word = previousWord == null? PickWordByProbability(profile) : PickWordByProbabilityWithPrediction(profile, previousWord); break; } return(word); }
public bool ProfileTimeLineHasTweets(TwitterProfile profile) { if (profile == null) { return(false); } if (profile.Name == null) { return(false); } var user = User.GetUserFromScreenName(profile.Name); if (user == null) { return(false); } var timelineParameter = Timeline.CreateHomeTimelineParameter(); timelineParameter.ExcludeReplies = true; timelineParameter.TrimUser = true; timelineParameter.IncludeEntities = false; var timeLine = Timeline.GetUserTimeline(user); return(timeLine != null); }
private Word PickWordByProbability(TwitterProfile profile) { var weights = profile.Words.Select(w => w.Occurrence).ToList(); var index = AlgorithmSelector.PickIndexWeighted(weights, _random); return(profile.Words[index].Word); }
public async Task <IEnumerable <Tweet> > GetAllTweetsFromProfile(TwitterProfile profile) { var tweets = await(from tweet in _context.Status where tweet.Type == StatusType.User && tweet.ScreenName == profile.Name select tweet).ToListAsync(); return(tweets.Select(tweet => new Tweet(tweet.Text))); }
public void AddProfile(TwitterProfile profile, int occurrence) { if (Profiles.Any(p => p.Name == profile.Name)) { return; } ProfileOccurances.Add(new ProfileOccurrance(profile, this, occurrence)); }
public ProfileOccurrance(TwitterProfile profile, BotOptions options) { Profile = profile; ProfileId = profile.Id.Value; BotOptions = options; BotOptionsId = options.Id.Value; Occurrence = 1; }
public Tweet(long twitterId, string text, DateTime createdAt, int userId, TwitterProfile user, int quoteCount, int replyCount, int retweetCount, int favoriteCount) { TwitterId = twitterId; Text = text; CreatedAt = createdAt; UserId = userId; User = user; QuoteCount = quoteCount; ReplyCount = replyCount; RetweetCount = retweetCount; FavoriteCount = favoriteCount; }
public byte[] SaveProfileImageToServer(TwitterProfile profile) { var profileImage = "https://twitter.com/" + profile.Name + "/profile_image?size=original"; using (WebClient client = new WebClient()) { client.DownloadFile(new Uri(profileImage), @"profile.jpg"); } string path = @"profile.jpg"; return(File.ReadAllBytes(path)); }
public WordOccurrence(Word word, TwitterProfile profile) { // TODO: Null-checks Word = word; WordId = word.Id.Value; TwitterProfile = profile; TwitterProfileId = profile.Id.Value; NextWordOccurrences = new List <NextWordOccurrence>(); Occurrence = 1; }
private Word PickWordByProbabilityWithPrediction(TwitterProfile profile, Word previousWord) { var word = profile.Words.SingleOrDefault(w => w.Word.Equals(previousWord)); if (word?.NextWordOccurrences == null || word.NextWordOccurrences.Count == 0) { return(PickWordByProbability(profile)); } var weights = word.NextWordOccurrences.Select(n => n.Occurrence).ToList(); var index = AlgorithmSelector.PickIndexWeighted(weights, _random); return(word.NextWordOccurrences[index].Word); }
private Word PickWordRandom(TwitterProfile profile) { var index = _random.Next(profile.Words.Count); return(profile.Words[index].Word); }
public async Task <bool> DoesTwitterUserExist(TwitterProfile profile) { var user = (await GetTwitterProfile(profile.Name)); return(user != null); }
public async Task <string> GetTwitterUserName(TwitterProfile profile) { return((await GetTwitterProfile(profile.Name)).Name); }