Example #1
0
        public void TestSplit1()
        {
            Spliter spliter = new Spliter();
            string  test    = "นายจะไปไหนหรอ";
            var     output  = spliter.SegmentByDictionary(test);

            var asset = new List <string>
            {
                "นาย",
                "จะ",
                "ไป",
                "ไหน",
                "หรอ"
            };

            foreach (var variable in output)
            {
                Console.WriteLine(variable);
            }
            Assert.AreEqual(asset.Count, output.Count);
            Assert.AreEqual(asset[0], output[0]);
            Assert.AreEqual(asset[1], output[1]);
            Assert.AreEqual(asset[2], output[2]);
            Assert.AreEqual(asset[3], output[3]);
            Assert.AreEqual(asset[4], output[4]);
        }
Example #2
0
        public void InputT()
        {
            Spliter spliter = new Spliter();
            string  text    = input.Text;
            var     word    = spliter.SegmentByDictionary(text);

            foreach (string value in word)
            {
                if (value == "ซอล")
                {
                    diceMs = rnd.Next(3);



                    if (CoutM == 0)
                    {
                        command_AI();
                    }
                    else if (CoutM == 1)
                    {
                        commandM();
                    }
                    else if (CoutM == 2)
                    {
                        commandE();
                    }
                }
            }
        }
Example #3
0
        public void TestSplit2()
        {
            var spliter = new Spliter();
            var test    = "ไอ้นี่ถ้าจะบ้า";
            var output  = spliter.SegmentByDictionary(test);

            var expect = new List <string> {
                "ไอ้",
                "นี่",
                "ถ้า",
                "จะ",
                "บ้า"
            };

            Assert.Equal(expect, output);
        }
Example #4
0
        public void TestSplit1()
        {
            var spliter = new Spliter();
            var test    = "นายจะไปไหนหรอ";
            var output  = spliter.SegmentByDictionary(test);

            var expect = new List <string> {
                "นาย",
                "จะ",
                "ไป",
                "ไหน",
                "หรอ"
            };

            Assert.Equal(expect, output);
        }
Example #5
0
        public void TestSplit2()
        {
            Spliter spliter = new Spliter();
            string  test    = "ไอ้นี่ถ้าจะบ้า";
            var     output  = spliter.SegmentByDictionary(test);

            var asset = new List <string>
            {
                "ไอ้",
                "นี่",
                "ถ้า",
                "จะ",
                "บ้า"
            };

            Assert.AreEqual(asset.Count, output.Count);
            Assert.AreEqual(asset[0], output[0]);
            Assert.AreEqual(asset[1], output[1]);
            Assert.AreEqual(asset[2], output[2]);
            Assert.AreEqual(asset[3], output[3]);
            Assert.AreEqual(asset[4], output[4]);
        }
Example #6
0
        public void command_AI()
        {
            int     cout = 0;
            string  line;
            string  Cache        = "CacheM.txt";
            Spliter spliter      = new Spliter();
            string  conversation = input.Text;
            var     word         = spliter.SegmentByDictionary(conversation);

            File.WriteAllLines(Cache, word, Encoding.UTF8);
            string[] readText           = File.ReadAllLines(Cache, Encoding.UTF8);
            System.IO.StreamReader file = new System.IO.StreamReader(Cache);
            List <string>          list = new List <string>();

            while ((line = file.ReadLine()) != null)
            {
                keyword.Items.Add(line);
                list.Add(line);
                cout++;


                if (readText.Contains("ช่วยอะไรหน่อย"))
                {
                    pictureBox3.Height = Sc.Height;
                    pictureBox3.Top    = Sc.Top;
                    panelB.BringToFront();
                    CoutM = 1;
                    say("พร้อมรับคำสั่งแล้ว");
                }
//-------------------------------------------------------------------------------------------------------------------
                else if (readText.Contains("หาข้อมูล"))
                {
                    pictureBox3.Height = F.Height;
                    pictureBox3.Top    = F.Top;
                    panelC.BringToFront();
                    CoutM = 2;
                    say("มาคุยกันเถอะ");
                }
                //-------------------------------------------------------------------------------------------------------------------



                else if (readText.Contains("ไง"))
                {
                    switch (diceMs)
                    {
                    case 0: say("สวัดดี"); break;

                    case 1: say("ไง"); break;

                    case 2: say("เจอกันอีกแล้ว"); break;

                    case 3: say("จ้า"); break;
                    }
                }
                else if (readText.Contains("สวัดดี"))
                {
                    switch (diceMs)
                    {
                    case 0: say("สวัสดี"); break;

                    case 1: say("ไง"); break;

                    case 2: say("เจอกันอีกแล้ว"); break;

                    case 3: say("จ้า"); break;
                    }
                }
                else if (readText.Contains("ตอนเช้า"))
                {
                    switch (diceMs)
                    {
                    case 0: say("อรุณสวัสดิ์จ้า"); break;

                    case 1: say("มอนิ่ง จ้า"); break;

                    case 2: say("รีปตืนเลย"); break;

                    case 3: say("จ้า"); break;
                    }
                }

                else if (readText.Contains("ฝันดี"))
                {
                    switch (diceMs)
                    {
                    case 0: say("ฝันดีนะ"); break;

                    case 1: say("ฝันดีจ้า"); break;

                    case 2: say("บายๆ"); break;

                    case 3: say("จ้า"); break;
                    }
                }



                //------------------------------------------------------------Add----------------------------------------//


                else
                {
                    switch (diceMs)
                    {
                    case 0: say("ไม่มีคำสั่ง"); break;

                    case 1: say("สอนฉันสิ"); break;

                    case 2: say("ยังไม่พิมดีๆอีก"); break;

                    case 3: say("ช่างพ่อง"); break;
                    }
                }
            }
        }
Example #7
0
        public void commandE()
        {
            int     cout = 0;
            string  line;
            string  Cache        = "CacheTwo.txt";
            Spliter spliter      = new Spliter();
            string  conversation = input.Text;
            var     word         = spliter.SegmentByDictionary(conversation);

            File.WriteAllLines(Cache, word, Encoding.UTF8);
            string[] readText           = File.ReadAllLines(Cache, Encoding.UTF8);
            System.IO.StreamReader file = new System.IO.StreamReader(Cache);
            List <string>          list = new List <string>();

            while ((line = file.ReadLine()) != null)
            {
                keyword.Items.Add(line);
                list.Add(line);
                cout++;
                int countst = word.Count;
                countst = countst - 2;



                if (readText[0] == ("อะไร") || readText[countst] == ("อะไร"))
                {
                    switch (diceMs)
                    {
                    case 0: say("อะไรนะสัส"); break;

                    case 1: say("กูไม่ตอบมึงหรอก"); break;

                    case 2: say("ช่างพ่อมึง"); break;

                    case 3: say("แล้วแต่มึงเลย"); break;
                    }
                }


                else if (readText[0] == ("ขอบคุณ"))
                {
                    pictureBox3.Height = Sc.Height;
                    pictureBox3.Top    = Sc.Top;
                    panelA.BringToFront();
                    CoutM = 0;
                    switch (diceMs)
                    {
                    case 0: say("เรียบร้อย"); break;

                    case 1: say("เสร็จแล้ว"); break;

                    case 2: say("เรียบ100"); break;

                    case 3: say("จ้า"); break;
                    }
                }


                //------------------------------------------------------------Add----------------------------------------//
            }
        }
Example #8
0
        public void commandM()
        {
            int     cout = 0;
            string  line;
            string  Cache        = "Cacheone.txt";
            Spliter spliter      = new Spliter();
            string  conversation = input.Text;
            var     word         = spliter.SegmentByDictionary(conversation);

            File.WriteAllLines(Cache, word, Encoding.UTF8);
            string[] readText           = File.ReadAllLines(Cache, Encoding.UTF8);
            System.IO.StreamReader file = new System.IO.StreamReader(Cache);
            List <string>          list = new List <string>();

            while ((line = file.ReadLine()) != null)
            {
                keyword.Items.Add(line);
                list.Add(line);
                cout++;
                int countst = word.Count;
                countst = countst - 2;


                if (readText.Contains("กี่โมง"))
                {
                    say("ขณะนี้เวลา" + DateTime.Now.ToString("h:mm tt"));
                }
                else if (readText.Contains("เปิดเฟสบุ๊ค"))
                {
                    Process.Start("http://facebook.com");
                    switch (diceMs)
                    {
                    case 0: say("เรียบร้อย"); break;

                    case 1: say("เสร็จแล้ว"); break;

                    case 2: say("เรียบ100"); break;

                    case 3: say("จ้า"); break;
                    }
                }


                else if (readText[0] == ("ใคร"))
                {
                    Process.Start("https://www.google.co.th/#q=" + (conversation) + "wikipedia");
                    switch (diceMs)
                    {
                    case 0: say("เรียบร้อย"); break;

                    case 1: say("เสร็จแล้ว"); break;

                    case 2: say("เรียบ100"); break;

                    case 3: say("จ้า"); break;
                    }
                    cler();
                }

                else if (readText[0] == ("ที่ไหน") || readText[countst] == ("ไหน"))
                {
                    Process.Start("https://www.google.co.th/maps/place/" + (conversation));
                    switch (diceMs)
                    {
                    case 0: say("เรียบร้อย"); break;

                    case 1: say("เสร็จแล้ว"); break;

                    case 2: say("เรียบ100"); break;

                    case 3: say("จ้า"); break;
                    }
                    cler();
                }



                else if (readText[0] == ("ขอบคุณ"))
                {
                    pictureBox3.Height = Sc.Height;
                    pictureBox3.Top    = Sc.Top;
                    panelA.BringToFront();
                    CoutM = 0;
                    switch (diceMs)
                    {
                    case 0: say("เรียบร้อย"); break;

                    case 1: say("เสร็จแล้ว"); break;

                    case 2: say("เรียบ100"); break;

                    case 3: say("จ้า"); break;
                    }
                }



                //------------------------------------------------------------Add----------------------------------------//
            }
        }