private void recursiveLearnFromFile(FileSystemObjectInfo info, bool recurse = false) { if ((info.FileSystemInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory) { var files = Directory.EnumerateFiles(info.FileSystemInfo.FullName, "*.*", SearchOption.TopDirectoryOnly) .Where(s => s.EndsWith(".txt", StringComparison.OrdinalIgnoreCase)); foreach (string path in files) { FileInfo fi = new FileInfo(path); FileSystemObjectInfo fsoi = new FileSystemObjectInfo(fi); recursiveLearnFromFile(fsoi); } } else { try { using (StreamReader sr = new StreamReader(info.FileSystemInfo.FullName)) { string line = sr.ReadToEnd(); Markov.Train(Context, line); Log("Batched file training complete"); } } catch (IOException ex) { Log("Error: The file could not be read:\n" + ex.Message); } } }
private void LearnManual() { Markov.Train(Context, LearnTextBox.Text); Log("Manual training complete"); if (Context.AutoClear) { LearnTextBox.Text = ""; } }