def pairs_quality(cand_rec_id_pair_list, true_match_set):
  """Pairs quality measures the efficiency of a blocking technique.

     Pairs quality is calculated as the number of true matches included in the
     candidate record pairs divided by the number of candidate record pairs
     generated by blocking.

     Parameter Description:
       cand_rec_id_pair_list : List of candidate record pairs generated
                               by a blocking technique
       true_match_set        : Set of true matches (record identifier pairs)

     The method returns a float value.
  """

  num_true_matches_block = 0
  num_comparisons =        len(cand_rec_id_pair_list)

  for rec_id_tuple in cand_rec_id_pair_list:

    if (rec_id_tuple in true_match_set):
      num_true_matches_block += 1

  pq = float(num_true_matches_block) / num_comparisons

  return pq