Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        private void LearnManual()
        {
            Markov.Train(Context, LearnTextBox.Text);

            Log("Manual training complete");

            if (Context.AutoClear)
            {
                LearnTextBox.Text = "";
            }
        }