예제 #1
0
 public AnswerQuality(QuestionList questionList)
 {
     this.questionList = questionList;
     userQuality = new UserQuality(questionList);
     foreach (var answer in questionList.GetAllAnswers().Where(answer => !answers.ContainsKey(answer.Id)))
     {
         answers.Add(answer.Id, answer);
     }
 }
예제 #2
0
        public static void ModifyTyposCorpus(QuestionList ql)
        {
            var detector = new SpellChecker(TrigramIndex.CreateFrom(ql));
            Console.WriteLine("I am Modifying");

            var start = DateTime.Now;
            foreach (var question in ql.GetAllQuestions())
            {
                question.Text = String.Join(" ", question.Text.SplitInWordsAndStripHTML().Select(detector.Fix));
                question.Title = String.Join(" ", question.Title.SplitInWordsAndStripHTML().Select(detector.Fix));
            }
            Console.WriteLine("Questions modified in {0}", (DateTime.Now - start).TotalSeconds);

            start = DateTime.Now;
            foreach (var answer in ql.GetAllAnswers())
            {
                answer.Text = String.Join(" ", answer.Text.SplitInWordsAndStripHTML().Select(detector.Fix));
            }
            Console.WriteLine("Answers modified in {0}", (DateTime.Now - start).TotalSeconds);

            File.WriteAllLines(Program.QuestionsNoTyposFileName, ql.GetAllQuestions().Select(Question.FormatStringWrite));
            File.WriteAllLines(Program.AnswersNoTyposFileName, ql.GetAllAnswers().Select(Answer.FormatStringWrite));
        }
예제 #3
0
        public UserStatistics(QuestionList questionList)
            : base(questionList)
        {
            var parser = new MailUserPageParser(Program.MailUsersDirectory);

            var questionUsers = questionList.GetAllQuestions().Select(q => q.AuthorEmail);
            var answerUsers = questionList.GetAllAnswers().Select(a => a.AuthorEmail);
            var questionListUsers = new HashSet<string>(questionUsers.Union(answerUsers));

            users = parser.GetObjects().Where(u => questionListUsers.Contains(u.Email)).ToList();

            TopicStatistics = new TopicsStatistics(questionList);
        }
예제 #4
0
			public void TestId()
			{
				var ql = new QuestionList(QuestionsFileName, AnswersFileName);
				var hasIdenticId = false;
				foreach (var question in ql.GetAllQuestions())
				{

					foreach (var answer in ql.GetAllAnswers())
					{
						hasIdenticId = true;
						if (answer.Id == question.Id)
							Console.WriteLine("BAD ID!!!!!!!!! " + answer.Id);
					}
					//Console.WriteLine(question.Id);
				}
				Assert.AreEqual(true, hasIdenticId);
			}
예제 #5
0
 private static IEnumerable<string> GetAllVertices(QuestionList ql)
 {
     return ql.GetAllQuestions().Select(q => q.AuthorEmail).Concat(ql.GetAllAnswers().Select(q => q.AuthorEmail)).Distinct();
 }