Пример #1
0
        static void Main(string[] args)
        {
            Markov Bot = new Markov();

            //*
            Bot.LoadAuxiliaries("Auxiliaries.txt");
            Bot.LoadBanList("Bans.txt");
            Bot.LoadSwapList("Swaps.txt");
            Bot.Train("Training.txt");
            Bot.SaveBrain("BRAIN");

            /*/
             * Bot.LoadBrain("BRAIN");
             * //*/
            while (true)
            {
                Console.Write("> ");
                String Text = null;
                while (Text == null)
                {
                    Text = Console.ReadLine();
                }

                Console.WriteLine(Bot.GenerateReply(Text));
            }
        }
Пример #2
0
    private void Awake()
    {
        _st = SettingsReader.GetInstance();
        _mn = GetComponent <Metronome>();
        R   = new Random();

        //var folder = new DirectoryInfo(Application.dataPath + "/");
        //var files = folder.GetFiles("*.notes", SearchOption.AllDirectories);
        //if (files.Length == 0) throw new Exception("No sample files found.");
        TextAsset prnFile = Resources.Load("input") as TextAsset;


        var sample  = new Markov <string>(" ");
        var content = new List <string>();

        char[] archDelim = new char[] { ' ' };
        string txt       = prnFile.text;

        content = txt.Split(archDelim, StringSplitOptions.RemoveEmptyEntries).ToList();

        //using (var sampleFile = new StreamReader(t.FullName))
        // {
        //while (!sampleFile.EndOfStream)
        // {
        //var line = sampleFile.ReadLine().Trim();
        //    foreach (var entry in line.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries))
        //      content.Add(entry);
        //}

        //sampleFile.Close();
        //}

        if (content.Count > 4)
        {
            sample.Train(content, 4);
        }

        _requiredWordCount = (int)_st.AudioLength;
        var result       = sample.GeneratePiece(_requiredWordCount, true);
        var resultString = new StringBuilder();

        foreach (var entry in result)
        {
            resultString.Append(entry + " ");
        }
        _mn.BuildNoteList(result);
    }
Пример #3
0
        static void Main(string[] args)
        {
            Markov bot = new Markov();
            //*
            var sw = Stopwatch.StartNew();

            bot.LoadAuxiliaries("../../Files/Auxiliaries.txt");
            sw.Stop();
            Console.WriteLine($"Auxiliaries {sw.Elapsed.TotalMilliseconds.ToString("N0")} ms");

            sw = Stopwatch.StartNew();
            bot.LoadBanList("../../Files/Bans.txt");
            sw.Stop();
            Console.WriteLine($"Bans {sw.Elapsed.TotalMilliseconds.ToString("N0")} ms");

            sw = Stopwatch.StartNew();
            bot.LoadSwapList("../../Files/Swaps.txt");
            sw.Stop();
            Console.WriteLine($"Swaps {sw.Elapsed.TotalMilliseconds.ToString("N0")} ms");

            sw = Stopwatch.StartNew();
            bot.Train("../../Files/Training.txt");
            sw.Stop();
            Console.WriteLine($"Training {sw.Elapsed.TotalMilliseconds.ToString("N0")} ms");

            sw = Stopwatch.StartNew();
            bot.SaveBrain("../../Files/BRAIN.dat");
            sw.Stop();
            Console.WriteLine($"BRAIN {sw.Elapsed.TotalMilliseconds.ToString("N0")} ms");

            /*/
             * Bot.LoadBrain("../../Files/BRAIN.dat");
             * //*/
            while (true)
            {
                Console.Write("> ");
                String text = null;
                while (text == null)
                {
                    text = Console.ReadLine();
                }

                Console.WriteLine(bot.GenerateReply(text));
            }
        }