Charty/download/files/ChartyPy.py
def ruleInvocation(lststart):
   """Add all the rules of the grammar to the chart that
      are relavant:
      Find the rule with the LHS of edge as the leftmost RHS
      symbol and maximally the remaining length of the input."""
   change = 0
   for i in range(lststart, len(chart)):
      if chart[i][2] >= len(chart[i][4]): # only inactive edge
         (start, end, index, lhs, rhs, consumed) = chart[i]
         if grammar.rhshash.has_key(lhs):
            for k in grammar.rhshash[lhs]:
               if len(grammar.rhs[k]) > inputlength - start:
                  continue
               newedge = [ start, end, 1, grammar.lhs[k], grammar.rhs[k], [i] ]
               if newedge in chart:
                  continue
               chart.append(newedge[:])
               change = 1
               if DEBUG:
                  print "RI Adding edge:", newedge
   return change
Add all the rules of the grammar to the chart that
      are relavant:
      Find the rule with the LHS of edge as the leftmost RHS
      symbol and maximally the remaining length of the input.
Add all the rules of the grammar to the chart that
are relavant:
Find the rule with the LHS of edge as the leftmost RHS
symbol and maximally the remaining length of the input.
Add all the rules of the grammar to the chart that are relavant : Find the rule with the LHS of edge as the leftmost RHS symbol and maximally the remaining length of the input .
def ruleInvocation(lststart):
   change = 0
   for i in range(lststart, len(chart)):
      if chart[i][2] >= len(chart[i][4]): 
         (start, end, index, lhs, rhs, consumed) = chart[i]
         if grammar.rhshash.has_key(lhs):
            for k in grammar.rhshash[lhs]:
               if len(grammar.rhs[k]) > inputlength - start:
                  continue
               newedge = [ start, end, 1, grammar.lhs[k], grammar.rhs[k], [i] ]
               if newedge in chart:
                  continue
               chart.append(newedge[:])
               change = 1
               if DEBUG:
                  print "RI Adding edge:", newedge
   return change
def ruleInvocation ( lststart ) : change = 0 for i in range ( lststart , len ( chart ) ) : if chart [ i ] [ 2 ] >= len ( chart [ i ] [ 4 ] ) : ( start , end , index , lhs , rhs , consumed ) = chart [ i ] if grammar . rhshash . has_key ( lhs ) : for k in grammar . rhshash [ lhs ] : if len ( grammar . rhs [ k ] ) > inputlength - start : continue newedge = [ start , end , 1 , grammar . lhs [ k ] , grammar . rhs [ k ] , [ i ] ] if newedge in chart : continue chart . append ( newedge [ : ] ) change = 1 if DEBUG : print "RI Adding edge:" , newedge return change
Add all the rules of the grammar to the chart that
are relavant:
Find the rule with the LHS of edge as the leftmost RHS
symbol and maximally the remaining length of the input.
Add all the rules of the grammar to the chart that are relavant : Find the rule with the LHS of edge as the leftmost RHS symbol and maximally the remaining length of the input .
"""Add all the rules of the grammar to the chart that
      are relavant:
      Find the rule with the LHS of edge as the leftmost RHS
      symbol and maximally the remaining length of the input.""" # only inactive edge
lststart