コード例 #1
0
ファイル: MainForm.cs プロジェクト: VuNamHa/l-thuy-t-NNLT
        private void test(string[] sent, EarleyParser parser)
        {
            StringBuilder output = new StringBuilder();

            for (int i = 0; i < sent.Length - 1; i++)
            {
                output.Append(sent[i] + " ");
            }

            output.Append(sent[sent.Length - 1] + ".");
            string sentence = output.ToString();

            textBox1.Text += "Sentence: " + sentence + "\r\n";
            bool successful = parser.parseSentence(sent);

            textBox1.Text += "Parse Sucessful: " + successful.ToString() + "\r\n";
            Chart[] charts = parser.getCharts();
            textBox1.Text += "Charts produced by the sentence: " + sentence + "\r\n";

            for (int i = 0; i < charts.Length; i++)
            {
                textBox1.Text += "Chart[" + i.ToString() + "] :\r\n";
                textBox1.Text += charts[i].ToString() + "\r\n";
            }

            textBox1.Text += "\r\n";
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: VuNamHa/l-thuy-t-NNLT
        private void test(string[] sent, EarleyParser parser)
        {
            StringBuilder output = new StringBuilder();

            for (int i = 0; i < sent.Length - 1; i++)
            {
                output.Append(sent[i] + " ");
            }

            output.Append(sent[sent.Length - 1] + ".");
            string sentence = output.ToString();

            textBox1.Text += "Xâu Input: " + sentence + "\r\n";
            bool successful = parser.parseSentence(sent);

            textBox1.Text += "Kết quả: " + successful.ToString() + "\r\n";
            Chart[] charts = parser.getCharts();
            textBox1.Text += "Bảng  phân tích trạng thái xâu: " + sentence + "\r\n";

            for (int i = 0; i < charts.Length; i++)
            {
                textBox1.Text += "Bảng[" + i.ToString() + "] :\r\n";
                textBox1.Text += charts[i].ToString() + "\r\n";
            }

            textBox1.Text += "\r\n";
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: VuNamHa/l-thuy-t-NNLT
        private void Work0()
        {
            string[] sentence1 = { "2", "+", "3", "*", "4" };

            Grammar      grammar = new SimpleGrammar1();
            EarleyParser parser  = new EarleyParser(grammar);

            test(sentence1, parser);
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: VuNamHa/l-thuy-t-NNLT
        private void Work1()
        {
            string[]     sentence1 = { "John", "called", "Mary" };
            string[]     sentence2 = { "John", "called", "Mary",
                                       "from",     "Denver" };
            Grammar      grammar = new SimpleGrammar();
            EarleyParser parser  = new EarleyParser(grammar);

            test(sentence1, parser);
            test(sentence2, parser);
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: VuNamHa/l-thuy-t-NNLT
        private void Work2()
        {
            string[] sentence3 = { "PaPa", "ate", "the", "caviar", "with", "a", "spoon" };
            //string[] sentence2 = { "John", "called", "Mary",
            //   "from", "Denver" };
            Grammar      grammar = new SimpleGrammar2();
            EarleyParser parser  = new EarleyParser(grammar);

            test(sentence3, parser);
            //test(sentence2, parser);
        }