Charty/download/files/ChartyPy.py
def parse(input):
   """Parse a list of tokens.
   """
   global chart
   global inputlength
   chart = []
   inputlength = len(input)

   chartpos = 0  # remember start-position in chart
   for i in range(len(input)):
      # initialize with input token
      chart.append([ i, i + 1, 1, grammar.getTag(input[i]), [ input[i] ], [] ])
      if DEBUG:
         print "Adding edge:", chart[len(chart) - 1]
      change = 1
      while change:
         change = 0
         chartlen = len(chart)
         if ruleInvocation(chartpos):
            change = 1
         chartpos = chartlen  # set pointer to new edge in chart
         if fundamentalRule():
            change = 1
   if DEBUG:
      print "Chart:"
      for i in range(len(chart)):
         if isActive(chart[i]):
            print i, "Active:  ",
         else:
            print i, "Inactive:",
         print chart[i]
   for i in getParse(inputlength, chart):
      print "Parse:"
      print i
Parse a list of tokens.
   
Parse a list of tokens.
Parse a list of tokens .
def parse(input):
   global chart
   global inputlength
   chart = []
   inputlength = len(input)
   chartpos = 0  
   for i in range(len(input)):
      chart.append([ i, i + 1, 1, grammar.getTag(input[i]), [ input[i] ], [] ])
      if DEBUG:
         print "Adding edge:", chart[len(chart) - 1]
      change = 1
      while change:
         change = 0
         chartlen = len(chart)
         if ruleInvocation(chartpos):
            change = 1
         chartpos = chartlen  
         if fundamentalRule():
            change = 1
   if DEBUG:
      print "Chart:"
      for i in range(len(chart)):
         if isActive(chart[i]):
            print i, "Active:  ",
         else:
            print i, "Inactive:",
         print chart[i]
   for i in getParse(inputlength, chart):
      print "Parse:"
      print i
def parse ( input ) : global chart global inputlength chart = [ ] inputlength = len ( input ) chartpos = 0 for i in range ( len ( input ) ) : chart . append ( [ i , i + 1 , 1 , grammar . getTag ( input [ i ] ) , [ input [ i ] ] , [ ] ] ) if DEBUG : print "Adding edge:" , chart [ len ( chart ) - 1 ] change = 1 while change : change = 0 chartlen = len ( chart ) if ruleInvocation ( chartpos ) : change = 1 chartpos = chartlen if fundamentalRule ( ) : change = 1 if DEBUG : print "Chart:" for i in range ( len ( chart ) ) : if isActive ( chart [ i ] ) : print i , "Active:  " , else : print i , "Inactive:" , print chart [ i ] for i in getParse ( inputlength , chart ) : print "Parse:" print i
Parse a list of tokens.
Parse a list of tokens .
"""Parse a list of tokens.
   """ # remember start-position in chart # initialize with input token # set pointer to new edge in chart
input