def slot_error_rate(text, slot_values, n_slots=1):
  """
  Estimates slot error rate as:
  err = (p + q) / n_slots
  where
  - p, q is the number of missing and redundant slots in the document.
  - n_slots is the total numberof slots in the document.
  """
  n = 0
  words = text.split(" ")
  for word in words:
    is_subj = False
    for alt in slot_values:
      if alt in word:
        is_subj = True
    if is_subj:
      n += 1
  pq = abs(n - n_slots)
  err = pq / float(n_slots)
  return err