public void Enter(NewWordsService service) { Console.WriteLine("Updating Db"); service.UpdateAgingAndRandomize(); var allModels = service.GetAll(); foreach (var pairModel in allModels) { Console.WriteLine( $"{pairModel.OriginWord} - {pairModel.Translation} score: {pairModel.PassedScore} / {pairModel.Examed} {pairModel.AggregateScore:##.##}"); } Console.WriteLine($"Has {allModels.Length} models"); var examSum = allModels.Sum(a => a.Examed); var passedSum = allModels.Sum(a => a.PassedScore); var passedAggregatedSum = allModels.Sum(a => Math.Min(1, a.PassedScore / (double)PairModel.MaxExamScore)); var passedCount = allModels.Count(a => a.PassedScore >= PairModel.MaxExamScore); var count = allModels.Length; Console.WriteLine($"Knowledge: {100 * passedAggregatedSum / (double)(count):##.##} %"); Console.WriteLine($"Known: {100 * passedCount / (double)(count):##.##} %"); Console.WriteLine($"Failures : {100 * passedSum / (double)(examSum):##.##} %"); }
public void Enter(NewWordsService service) { var allWords = service.GetAll(); RenderKnowledgeHistogram(allWords); Console.WriteLine(); Console.WriteLine(); RenderAddingTimeLine(allWords); RenderExamsTimeLine(service.GetAllExams()); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); Console.WriteLine(); Console.WriteLine($"Context phrases count = {service.GetContextPhraseCount()}"); Console.WriteLine($"Words count = {allWords.Count(w=>!w.OriginWord.Contains(' '))}"); Console.WriteLine($"Words and sentences count = {allWords.Length}"); var groups = allWords .GroupBy(s => s.State) .OrderBy(s => (int)s.Key) .Select(s => new { state = s.Key, count = s.Count() }); var doneCount = allWords.Count(a => a.PassedScore >= PairModel.MaxExamScore); Console.WriteLine($"Done: {doneCount} words ({(doneCount * 100 / allWords.Length)}%)"); Console.WriteLine($"Unknown: {allWords.Length - doneCount} words"); Console.WriteLine(); var learningRate = GetLearningRate(allWords); Console.WriteLine("Score is " + learningRate); if (learningRate < 100) { Console.WriteLine("You has to add more words!"); } else if (learningRate < 200) { Console.WriteLine("It's time to add new words!"); } else if (learningRate < 300) { Console.WriteLine("Zen!"); } else if (learningRate < 400) { Console.WriteLine("Let's do some exams"); } else { Console.WriteLine("Exams exams exams!"); Console.WriteLine($"You have to make at least {(learningRate-300)/10} more exams"); } }
public void Enter(NewWordsService service) { int phraselessCount = 0; var allWords = service.GetAll(); int newPhrases = 0; foreach (var pairModel in allWords) { if (pairModel.Revision >= 1) { continue; } var translateTask = _client.Translate(pairModel.OriginWord); translateTask.Wait(); var yaTranslations = translateTask.Result.SelectMany(r => r.Tr).Select(s => s.Text.Trim().ToLower()); var originTranlations = pairModel.Translation.Split(',', StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Trim().ToLower()); pairModel.AllMeanings = string.Join(";;", yaTranslations.Union(originTranlations).Distinct()); var withPhrases = service.GetOrNullWithPhrases(pairModel.OriginWord); if (!withPhrases.Phrases.Any() || (withPhrases.Phrases.Count == 1 && withPhrases.Phrases[0].IsEmpty)) { var allPhrases = translateTask.Result.SelectMany(r => r.Tr).SelectMany(r => r.GetPhrases(pairModel.OriginWord)).ToList(); foreach (var phrase in allPhrases) { service.Add(phrase); newPhrases++; } if (!allPhrases.Any()) { phraselessCount++; } } pairModel.Revision = 1; service.UpdateRatings(pairModel); Console.Write("."); } Console.WriteLine("new phrases:" + newPhrases); Console.WriteLine("Phraseless count:" + phraselessCount); Console.WriteLine("withPhrases:" + (allWords.Length - phraselessCount)); }
public async Task Enter() { var allWords = _wordsService.GetAll(); /* * //todo Histogram output * * var historgramMessage = new StringBuilder(); * historgramMessage.Append("```\r\n"); * RenderKnowledgeHistogram(allWords,historgramMessage); * historgramMessage.Append("```\r\n"); * await _chat.SendMessage(historgramMessage.ToString()); * historgramMessage.Clear(); * * historgramMessage.Append("```\r\n"); * RenderAddingTimeLine(allWords,historgramMessage); * historgramMessage.Append("```\r\n"); * await _chat.SendMessage(historgramMessage.ToString()); * historgramMessage.Clear(); * * historgramMessage.Append("```\r\n"); * RenderExamsTimeLine(_wordsService.GetAllExams(),historgramMessage); * historgramMessage.Append("```\r\n"); * await _chat.SendMessage(historgramMessage.ToString()); */ var sb = new StringBuilder(); sb.AppendLine($"Context phrases count = {_wordsService.GetContextPhraseCount()}"); sb.AppendLine($"Words count = {allWords.Count(w=>!w.OriginWord.Contains(' '))}"); sb.AppendLine($"Words and sentences count = {allWords.Length}"); var groups = allWords .GroupBy(s => s.State) .OrderBy(s => (int)s.Key) .Select(s => new { state = s.Key, count = s.Count() }); var doneCount = allWords.Count(a => a.PassedScore >= PairModel.MaxExamScore); sb.AppendLine($"Done: {doneCount} words ({(doneCount * 100 / allWords.Length)}%)"); sb.AppendLine($"Unknown: {allWords.Length - doneCount} words"); sb.AppendLine(); var learningRate = GetLearningRate(allWords); Console.WriteLine("Score is " + learningRate); if (learningRate < 100) { sb.AppendLine("You have to add more words!"); } else if (learningRate < 200) { sb.AppendLine("It's time to add new words!"); } else if (learningRate < 300) { sb.AppendLine("Zen!"); } else if (learningRate < 400) { sb.AppendLine("Let's do some exams"); } else { sb.AppendLine("Exams exams exams!"); sb.AppendLine($"You have to make at least {(learningRate-300)/10} more exams"); } var __ = _chat.SendMessage(sb.ToString()); }