code: def segment_similarity(A, B, T=CLOSE_DISTANCE_THRESHOLD):
      
      l_a = len(A.points)
      l_b = len(B.points)
  
      idx = index.Index()
      dex = 0
      for i in range(l_a-1):
          idx.insert(dex, bounding_box_from(A.points, i, i+1, T), obj=[A.points[i], A.points[i+1]])
          dex = dex + 1
  
      prox_acc = []
  
      for i in range(l_b-1):
          ti = B.points[i].gen2arr()
          ti1 = B.points[i+1].gen2arr()
          bb = bounding_box_from(B.points, i, i+1, T)
          intersects = idx.intersection(bb, objects=True)
          n_prox = []
          i_prox = 0
          a = 0
          for x in intersects:
              a = a + 1
              pi = x.object[0].gen2arr()
              pi1 = x.object[1].gen2arr()
              prox = line_similarity(ti, ti1, pi, pi1, T)
              i_prox = i_prox + prox
              n_prox.append(prox)
  
          if a != 0:
              prox_acc.append(i_prox / a)
              # prox_acc.append(max(n_prox))
          else:
              prox_acc.append(0)
  
      return np.mean(prox_acc), prox_acc
docs: Computes the similarity between two segments
  
      Args:
          A (:obj:`Segment`)
          B (:obj:`Segment`)
      Returns:
          float: between 0 and 1. Where 1 is very similar and 0 is completely different