// Computes Gunning Fog score private static void GunningFog(LinguisticAnalysis analysis, StringBuilder commentToPost) { double index = 0.4 * ((analysis.GetWords() / analysis.GetSentences()) + analysis.GetPercentageHardWords()); index = Math.Round(index, 4, MidpointRounding.AwayFromZero); commentToPost.Append(String.Format("`Gunning Fog Grade Level: {0}`\n\n", index)); }
static int Main(string[] args) { Reddit reddit = new Reddit(); Login(reddit); Subreddit subreddit = GetFrontPage(reddit); IEnumerable<Post> topPosts = GetTopPosts(subreddit); Subreddit subredditToPostTo = reddit.GetSubreddit("readability"); foreach (Post post in topPosts) { StringBuilder commentToPost = new StringBuilder(String.Format("Thread link: http://www.reddit.com/{0}\n\n***\n\n", post.Id)); List<Comment> topComments = GetTopComments(post); foreach (Comment comment in topComments) { commentToPost.Append(String.Format("\"{0}\"\n\n", comment.Body)); // Removes formatting so that linguistic analysis works properly string commentText = comment.Body; RemoveFormatting(ref commentText); LinguisticAnalysis analysis = new LinguisticAnalysis(commentText); commentToPost.Append(String.Format("`Words: {0}`\n\n`Characters: {1}`\n\n`Sentences: {2}`\n\n`Syllables: {3}`\n\n`% Hard Words: {4}`\n\n", analysis.GetWords(), analysis.GetCharacters(), analysis.GetSentences(), analysis.GetSyllables(), analysis.GetPercentageHardWords())); ReadabilityAnalysis(analysis, commentToPost); commentToPost.Append("***\n\n"); } PostRedditThread(subredditToPostTo, post.Title, commentToPost); } Console.WriteLine(LOG_SUCCESSFUL_RUN); Console.Read(); // Remove later return 1; }