private static void CYKTest() { string[] nonterminals = new[] { "S" }, terminals = new[] { "0", "1" }; string starting = "S"; ProductionInfo[] rules = new[] { new ProductionInfo("S", new[] {"0", "S", "1"}), new ProductionInfo("S", new string[] {}) }; var contextFreeGrammar = new ContextFreeGrammar(nonterminals, terminals, rules, starting); var normalForm = contextFreeGrammar.GetChomskyNormalForm(); string[] sentence1 = new[] { "0", "1", "1", "0", "0", "0" }, sentence2 = new[] { "0", "0", "0", "1", "1", "1" }; Debug.Assert(!normalForm.HasSentence(sentence1)); Debug.Assert(normalForm.HasSentence(sentence2)); }
private static void CYKTest() { string[] nonterminals = new[] { "S" }, terminals = new[] { "0", "1" }; string starting = "S"; ProductionInfo[] rules = new[] { new ProductionInfo("S", new[] { "0", "S", "1" }), new ProductionInfo("S", new string[] {}) }; var contextFreeGrammar = new ContextFreeGrammar(nonterminals, terminals, rules, starting); var normalForm = contextFreeGrammar.GetChomskyNormalForm(); string[] sentence1 = new[] { "0", "1", "1", "0", "0", "0" }, sentence2 = new[] { "0", "0", "0", "1", "1", "1" }; Debug.Assert(!normalForm.HasSentence(sentence1)); Debug.Assert(normalForm.HasSentence(sentence2)); }