input: Write a function that initializes a Python class named "StringComparator" which takes two strings as input and offers methods to compare these strings. The class should have three methods: one to check whether the strings are exactly equal, another to check if they are different, and a third method to determine if the strings are similar based on an optional similarity threshold. If no threshold is provided, it should default to 0.5. The similarity is determined by comparing the edit distance between the strings divided by the maximum length of the two strings. Return True if the strings are similar within the threshold, otherwise return False.
  
  class StringComparator:
  
  def __init__(self, string1, string2):
   self.string1 = string1
   self.string2 = string2
  
  def is_equal(self):
   return self.string1 == self.string2
  
  def is_different(self):
   return self.string1 != self.string2
  
  def is_similar(self, threshold=0.5):
   distance = edit_distance(self.string1, self.string2)
   max_length = max(len(self.string1), len(self.string2))
  
   return distance / max_length < threshold
  
  assert StringComparator("hello", "hello").is_equal() == True
  assert StringComparator("hello", "world").is_equal() == False
  assert StringComparator("hello", "olleh").is_different() == True
  assert StringComparator("hello", "world").is_similar() == False
  assert StringComparator("hello", "hella").is_similar(threshold=0.3) == True
output: 
  def __init__(self, string1, string2):
      self.string1 = string1
      self.string2 = string2
  
  def is_equal(self):
      return self.string1 == self.string2
  
  def is_different(self):
      return self.string1 != self.string2
  
  def is_similar(self, threshold=0.5):
      def edit_distance(s1, s2):
          if len(s1) > len(s2):
              s1, s2 = s2, s1
          distances = range(len(s1) + 1)
          for i2, c2 in enumerate(s2):
              distances_ = [i2+1]
              for i1, c1 in enumerate(s1):
                  if c1 == c2:
                      distances_.append(distances[i1])
                  else:
                      distances_.append(1 + min((distances[i1], distances[i1 + 1], distances_[-1])))
              distances = distances_
          return distances[-1]
  
      distance = edit_distance(self.string1, self.string2)
      max_length = max(len(self.string1), len(self.string2))
      return distance / max_length < threshold
  