// Display console information for training. public void RenderTrainBook(InsightFacade insightFacade) { Console.WriteLine("\nInput the ids of books to be combined, books must already " + "be added, min 2. Format: id1,id2,...,idN"); var ids = Console.ReadLine().Split(","); var addedIds = insightFacade.ListBooks(); foreach (var id in ids) { if (!IdUtil.IdAlreadyAdded(id, addedIds) || !IdUtil.IsValid(id)) { Console.WriteLine($"Aborting, id: {id} is invalid."); return; } } Console.WriteLine($"\nA sentence will be displayed, followed by {_numAdjacentExamples} other " + $"sentences. Rank the {_numAdjacentExamples} from best to worst as the next sentence. " + $"Right is best, left is worst.\n"); try { insightFacade.TrainModel(ids.ToList(), _numExamplesToClassify, _numAdjacentExamples); Console.WriteLine("Model trained."); } catch (Exception e) { Console.WriteLine("Model not trained. " + e.Message); return; } }
// Display console information for listing added books. public void RenderListBook(InsightFacade insightFacade) { var addedBooks = insightFacade.ListBooks(); var idString = new StringBuilder(); for (int i = 0; i < addedBooks.Count - 1; i++) { idString.Append(addedBooks[i] + ", "); } if (addedBooks.Count == 0) { Console.WriteLine("\nNo books added."); return; } idString.Append(addedBooks[addedBooks.Count - 1]); Console.WriteLine("\nAdded book ids: " + idString.ToString()); }