Charty/resources/ChartyPy.py
def ruleInvocation(lststart, chart, inputlength, grammar):
   """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.

      Parameters:
      lststart - start position at edge in chart
      chart - the current chart
      inputlength - the length of the input sentence
      grammar - the grammar object raturned by PSGParse
   """
   change = False
   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]
         for k in grammar.rhshash.get(lhs, ()):
            if len(k[1]) > inputlength - start:
               continue
            newedge = ( start, end, 1, k[0], k[1], (i,) )
            if newedge in chart:
               continue
            chart.append(newedge)
            change = True
            if DEBUG:
               print "RI Adding edge:", edgeStr(newedge, grammar)
   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.

      Parameters:
      lststart - start position at edge in chart
      chart - the current chart
      inputlength - the length of the input sentence
      grammar - the grammar object raturned by PSGParse
   
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.

start position at edge in chart
chart - the current chart
inputlength - the length of the input sentence
grammar - the grammar object raturned by PSGParse
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 . start position at edge in chart chart - the current chart inputlength - the length of the input sentence grammar - the grammar object raturned by PSGParse
def ruleInvocation(lststart, chart, inputlength, grammar):
   change = False
   for i in range(lststart, len(chart)):
      if chart[i][2] >= len(chart[i][4]): 
         (start, end, index, lhs, rhs, consumed) = chart[i]
         for k in grammar.rhshash.get(lhs, ()):
            if len(k[1]) > inputlength - start:
               continue
            newedge = ( start, end, 1, k[0], k[1], (i,) )
            if newedge in chart:
               continue
            chart.append(newedge)
            change = True
            if DEBUG:
               print "RI Adding edge:", edgeStr(newedge, grammar)
   return change
def ruleInvocation ( lststart , chart , inputlength , grammar ) : change = False for i in range ( lststart , len ( chart ) ) : if chart [ i ] [ 2 ] >= len ( chart [ i ] [ 4 ] ) : ( start , end , index , lhs , rhs , consumed ) = chart [ i ] for k in grammar . rhshash . get ( lhs , ( ) ) : if len ( k [ 1 ] ) > inputlength - start : continue newedge = ( start , end , 1 , k [ 0 ] , k [ 1 ] , ( i , ) ) if newedge in chart : continue chart . append ( newedge ) change = True if DEBUG : print "RI Adding edge:" , edgeStr ( newedge , grammar ) 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.

      Parameters:
      lststart - start position at edge in chart
      chart - the current chart
      inputlength - the length of the input sentence
      grammar - the grammar object raturned by PSGParse
   """ # only inactive edge
lststart
chart
inputlength
grammar