Example #1
0
        public void SaveUserFirstNames()
        {
            const string malePath = "MaleNamesRating.txt";
            const string femalePath = "FemaleNamesRating.txt";

            var userNames =
                userStatistics.GetUserNames().Select(kv => Regex.Split(kv.Key, @"\W+").FirstOrDefault(part => part != "")).Where(
                    n => n != null).Select(n => n.ToLower()).GroupBy(
                        name => name, (key, ns) => Tuple.Create(key, ns.Count())).OrderByDescending(n => n.Item2);

            var genderDetector = new GenderDetector();
            var genders = userNames.Select(n => Tuple.Create(n.Item1, n.Item2, genderDetector.Detect(n.Item1))).ToList();

            File.WriteAllLines(malePath, genders.Where(n => n.Item3 == GenderDetector.Gender.Male).Select(n => n.Item1 + "\t" + n.Item2));
            File.WriteAllLines(femalePath, genders.Where(n => n.Item3 == GenderDetector.Gender.Female).Select(n => n.Item1 + "\t" + n.Item2));
        }
Example #2
0
        public void TestUserNames()
        {
            var userNames = userStatistics.GetUserNames().OrderByDescending(u => u.Value);
            var genderDetector = new GenderDetector();
            var genders = userNames.Select(n => Tuple.Create(n.Key, genderDetector.Detect(n.Key))).ToList();
            Console.WriteLine("Male %: " + (double)genders.Count(g => g.Item2 == GenderDetector.Gender.Male) / genders.Count);
            Console.WriteLine("Female %: " + (double)genders.Count(g => g.Item2 == GenderDetector.Gender.Female) / genders.Count);
            Console.WriteLine("Unknown %: " + (double)genders.Count(g => g.Item2 == GenderDetector.Gender.Unknown) / genders.Count);

            Console.WriteLine(userNames.Sum(u => u.Value));
            Console.WriteLine("Unknowns");
            Console.WriteLine(String.Join("\n", genders.Where(g => g.Item2 == GenderDetector.Gender.Unknown).Select(u => u.Item1)));
            //			Console.WriteLine("Males");
            //			Console.WriteLine(String.Join("\n", genders.Where(g => g.Item2 == GenderDetector.Gender.Male).Select(u => u.Item1)));
            //			Console.WriteLine("Females");
            //			Console.WriteLine(String.Join("\n", genders.Where(g => g.Item2 == GenderDetector.Gender.Female).Select(u => u.Item1)));
        }
Example #3
0
 public void SaveAllStatistics()
 {
     var genderDetector = new GenderDetector();
     var users = userStatistics.GetUsers().ToDictionary(u => u.Email, u => u);
     File.WriteAllLines("FullQuestionStatistics.txt",
                        medicalQuestions.GetAllQuestions().Select(
                            a =>
                                {
                                    var topic = userStatistics.TopicStatistics.GetTopicByQuestionId(a.Id, 0.1) ??
                                                Tuple.Create(-1, 0.0);
                                    return a.Id + "\t" + 0 + "\t" +
                                           a.Category + "\t" + a.Rating +
                                           "\t" +
                                           a.DateAdded + "\t" +
                                           topic.Item1 + "\t" + topic.Item2.ToString(CultureInfo.InvariantCulture) + "\t" +
                                           a.WholeText +
                                           "\t" +
                                           a.AuthorEmail + "\t" + a.AuthorRating + "\t" + a.AuthorEfficiency.ToString(CultureInfo.InvariantCulture) +
                                           "\t" +
                                           (users.ContainsKey(a.AuthorEmail)
                                                ? (users[a.AuthorEmail].BirthDate + "\t" +
                                                   users[a.AuthorEmail].Geo +
                                                   "\t" +
                                                   (String.IsNullOrEmpty(users[a.AuthorEmail].Name)
                                                        ? "Unknown"
                                                        : genderDetector.Detect(users[a.AuthorEmail].Name).
                                                              ToString()))
                                                : "\t\t");
                                }));
 }