0

i have the following code:

def ViCYK(grammar, sentenceToParse):
    treeChart = []
    probChart = []

    for i in range(0,len(sentenceToParse)):
            row = []
            for j in range(0,len(sentenceToParse)):
                        row.append(set())
            treeChart.append(row)
            probChart.append(row)


    for i in range(0,len(sentenceToParse)):
            for rule in grm.rules_right_to_left[(sentenceToParse[i],)]:
                    treeChart[i][i+1].add(rule)



    print 't ', treeChart
    print 'p ', probChart

let grm.rules_left_to_right be an dictionary containing some rules.

My assumed output would be, that the list treeChart does now contain some filled sets, where as the the sets in probChart remain empty, because I did not fill them in the second loop.

In contrast, the output looks as follows:

>>> ViCYK(grm, ['The','The'])
t  [[set(['ART']), set([])], [set([]), set(['ART'])]]
p  [[set(['ART']), set([])], [set([]), set(['ART'])]]

Can anyone help or explain? I'm afraid the solution is very obvious, but I just can not see it.

Thanks,

b

bngschmnd
  • 111
  • 1
  • 10

0 Answers0