def aprf_relationwise(g):
  """Returns precision, recall and F score for each relation."""
  rel_to_stats = collections.defaultdict(list)
  for item in g:
    rel_to_stats[item[0]].append(item)
  rel_to_scores = {}
  for rel, stats in rel_to_stats.items():
    rel_to_scores[rel] = [aprf(stats), len(stats)]
  return rel_to_scores
Returns precision, recall and F score for each relation.
language/labs/drkit/evaluate.py