parameters: (self, mainEntry, inflectionRuleData, start, end)
return_statement: return utf8_str(byteArray.tostring())
docstring: Apply inflection rule.
  
          @param mainEntry: The word to inflect.
          @param inflectionRuleData: The inflection rules.
          @param start: The start position of the inflection rule to use.
          @param end: The end position of the inflection rule to use.
          @return: The string with the inflected word or None if an error occurs.
docstring_summary: Apply inflection rule.
docstring_tokens: Apply inflection rule .
function: def applyInflectionRule(self, mainEntry, inflectionRuleData, start, end):
          '''
          Apply inflection rule.
  
          @param mainEntry: The word to inflect.
          @param inflectionRuleData: The inflection rules.
          @param start: The start position of the inflection rule to use.
          @param end: The end position of the inflection rule to use.
          @return: The string with the inflected word or None if an error occurs.
          '''
          mode = -1
          byteArray = array.array(array_format, mainEntry)
          position = len(byteArray)
          for charOffset in range(start, end):
              char = inflectionRuleData[charOffset:charOffset+1]
              abyte = ord(char)
              if abyte >= 0x0a and abyte <= 0x13:
                  # Move cursor backwards
                  offset = abyte - 0x0a
                  if mode not in [0x02, 0x03]:
                      mode = 0x02
                      position = len(byteArray)
                  position -= offset
              elif abyte > 0x13:
                  if mode == -1:
                      print("Error: Unexpected first byte %i of inflection rule" % abyte)
                      return None
                  elif position == -1:
                      print("Error: Unexpected first byte %i of inflection rule" % abyte)
                      return None
                  else:
                      if mode == 0x01:
                          # Insert at word start
                          byteArray.insert(position, abyte)
                          position += 1
                      elif mode == 0x02:
                          # Insert at word end
                          byteArray.insert(position, abyte)
                      elif mode == 0x03:
                          # Delete at word end
                          position -= 1
                          deleted = byteArray.pop(position)
                          if bchr(deleted) != char:
                              if DEBUG_DICT:
                                  print("0x03: %s %s %s %s" % (mainEntry, toHex(inflectionRuleData[start:end]), char, bchr(deleted)))
                              print("Error: Delete operation of inflection rule failed")
                              return None
                      elif mode == 0x04:
                          # Delete at word start
                          deleted = byteArray.pop(position)
                          if bchr(deleted) != char:
                              if DEBUG_DICT:
                                  print("0x03: %s %s %s %s" % (mainEntry, toHex(inflectionRuleData[start:end]), char, bchr(deleted)))
                              print("Error: Delete operation of inflection rule failed")
                              return None
                      else:
                          print("Error: Inflection rule mode %x is not implemented" % mode)
                          return None
              elif abyte == 0x01:
                  # Insert at word start
                  if mode not in [0x01, 0x04]:
                      position = 0
                  mode = abyte
              elif abyte == 0x02:
                  # Insert at word end
                  if mode not in [0x02, 0x03]:
                      position = len(byteArray)
                  mode = abyte
              elif abyte == 0x03:
                  # Delete at word end
                  if mode not in [0x02, 0x03]:
                      position = len(byteArray)
                  mode = abyte
              elif abyte == 0x04:
                  # Delete at word start
                  if mode not in [0x01, 0x04]:
                      position = 0
                  # Delete at word start
                  mode = abyte
              else:
                  print("Error: Inflection rule mode %x is not implemented" % abyte)
                  return None
          return utf8_str(byteArray.tostring())
function_tokens: def applyInflectionRule ( self , mainEntry , inflectionRuleData , start , end ) : mode = - 1 byteArray = array . array ( array_format , mainEntry ) position = len ( byteArray ) for charOffset in range ( start , end ) : char = inflectionRuleData [ charOffset : charOffset + 1 ] abyte = ord ( char ) if abyte >= 0x0a and abyte <= 0x13 : # Move cursor backwards offset = abyte - 0x0a if mode not in [ 0x02 , 0x03 ] : mode = 0x02 position = len ( byteArray ) position -= offset elif abyte > 0x13 : if mode == - 1 : print ( "Error: Unexpected first byte %i of inflection rule" % abyte ) return None elif position == - 1 : print ( "Error: Unexpected first byte %i of inflection rule" % abyte ) return None else : if mode == 0x01 : # Insert at word start byteArray . insert ( position , abyte ) position += 1 elif mode == 0x02 : # Insert at word end byteArray . insert ( position , abyte ) elif mode == 0x03 : # Delete at word end position -= 1 deleted = byteArray . pop ( position ) if bchr ( deleted ) != char : if DEBUG_DICT : print ( "0x03: %s %s %s %s" % ( mainEntry , toHex ( inflectionRuleData [ start : end ] ) , char , bchr ( deleted ) ) ) print ( "Error: Delete operation of inflection rule failed" ) return None elif mode == 0x04 : # Delete at word start deleted = byteArray . pop ( position ) if bchr ( deleted ) != char : if DEBUG_DICT : print ( "0x03: %s %s %s %s" % ( mainEntry , toHex ( inflectionRuleData [ start : end ] ) , char , bchr ( deleted ) ) ) print ( "Error: Delete operation of inflection rule failed" ) return None else : print ( "Error: Inflection rule mode %x is not implemented" % mode ) return None elif abyte == 0x01 : # Insert at word start if mode not in [ 0x01 , 0x04 ] : position = 0 mode = abyte elif abyte == 0x02 : # Insert at word end if mode not in [ 0x02 , 0x03 ] : position = len ( byteArray ) mode = abyte elif abyte == 0x03 : # Delete at word end if mode not in [ 0x02 , 0x03 ] : position = len ( byteArray ) mode = abyte elif abyte == 0x04 : # Delete at word start if mode not in [ 0x01 , 0x04 ] : position = 0 # Delete at word start mode = abyte else : print ( "Error: Inflection rule mode %x is not implemented" % abyte ) return None return utf8_str ( byteArray . tostring ( ) )