CKY

by togrli on January 28th, 2012
No notes
Syntax: C#
Show lines - Hide lines - Show in textbox - Download
            for (int j = 1; j <n+1 ; j++){//row #s
                if (debug) { Console.WriteLine("j = {0}, word = {1}", j, sentenceAr[j - 1]); }
                //matrix[0,j].Add(sentenceAr[j-1]);//make row 0 equal to word, 0,0 is left empty
                matrix[j - 1, j] = new List<string>(); matrix[j - 1, j].AddRange(getRHSstring(cnf_grammar, sentenceAr[j - 1])); //list of possible lex parses
                if (debug) { Console.WriteLine("added {0} to {1},{2}", cellToString(matrix[j - 1, j]),j-1,j); }
                for (int i = (j - 2); i >= 0; i--)
                {
                    if (debug) { Console.WriteLine("i = {0}", i); }
                    for (int k = i + 1; k < j; k++)
                    {
                        if (debug) { Console.WriteLine("k = {0}; {1},{2} & {3},{4}\t{5} | {6}", k, i, k, k, j, cellToString(matrix[i, k]), cellToString(matrix[k, j])); }//, matrix[i, k].ToString(), matrix[k, j].ToString());
                        HashSet<RHS> comboList = listCombinations(matrix[i, k], matrix[k, j]);
                        List<Production> productionPoss = checkProductions(comboList,cnf_grammar);//returns a list of productions, 
                        if (debug) { Console.WriteLine("production poss[{0}] ct = {1}",prodListToString(productionPoss),productionPoss.Count); }
 
                        if (productionPoss.Count > 0) { index_production.Add(i.ToString() + "_" + j.ToString() + "_" + k, productionPoss); }
                        List<string> LHS_poss = getLHSstring(productionPoss);
                        matrix[i, j]= new List<string>(); matrix[i,j].AddRange(LHS_poss);//add this list using AddRange to the current list of possibilites in this matrix cell (representing span)
                    }
                }
 
            }
 

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS