protected void DisplayParseText() { CKY_TableCell[,] TbCells = CKY_TABLECELLS; if (TbCells[0, N_Word].Tag != "") { string ParseText = CKY_Trace(0, N_Word, TbCells); var msg = String.Format("<strong>Success!</strong> Parse: {0}", ParseText); ScriptManager.RegisterStartupScript(MainUpdatePanel, MainUpdatePanel.GetType(), "alert", "ShowSuccessAlert('" + msg + "')", true); } else { var msg = String.Format("<strong>Fail!</strong> This is not a Sentence."); ScriptManager.RegisterStartupScript(MainUpdatePanel, MainUpdatePanel.GetType(), "alert", "ShowDangerAlert('" + msg + "')", true); } }
protected bool Start() { List <CNF_Rule> cnf_rules = new List <CNF_Rule>(); List <string> words = new List <string>(); List <string> sentence_words = new List <string>(); string CNF_text = CNF_Text.Value; string sentence = Sentence_Text.Value; string[] lines = CNF_text.Split(new string[] { "\n" }, StringSplitOptions.None); //string[] lines = CNF_text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); for (int i = 0; i < lines.Length; i++) { CNF_Rule rule = new CNF_Rule(i + 1, lines[i], words); cnf_rules.Add(rule); } Display_CNF_Table(cnf_rules); string[] wordsinSentence = sentence.Split(new char[] { ' ', ',', '.' }, StringSplitOptions.RemoveEmptyEntries); if (wordsinSentence.Count() == 0) { var msg = "<strong>Warning!</strong> The Sentence is empty."; ScriptManager.RegisterStartupScript(MainUpdatePanel, MainUpdatePanel.GetType(), "alert", "ShowWarningAlert('" + msg + "')", true); return(false); } List <string> Outlier_words = new List <string>(); // Check if error not have word in Global CNF WORDS foreach (string w in wordsinSentence) { if (words.IndexOf(w) == -1) { Outlier_words.Add(w); } else { sentence_words.Add(w); } } if (Outlier_words.Count() > 0) { var str_words = String.Join(", ", Outlier_words.ToArray()); var msg = String.Format("<strong>Warning!</strong> Words:<strong>{0}</strong> in the Sentence are not in CNF-Terminal words.", str_words); ScriptManager.RegisterStartupScript(MainUpdatePanel, MainUpdatePanel.GetType(), "alert", "ShowWarningAlert('" + msg + "')", true); //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowWarningAlert('" + msg + "')", true); return(false); } this.CNF_RULES = cnf_rules; this.WORDS = words; this.SENTENCE_WORDS = sentence_words; Display_CKY_Table(wordsinSentence); return(true); }