(gt:List[List], res:List[List], cmp_blank=True)
return precision, recall
Evaluate results

  Args:
    gt: a list of list of Relation
    res: a list of list of Relation
Evaluate results
Evaluate results
def eval_relations(gt:List[List], res:List[List], cmp_blank=True):
  """Evaluate results

  Args:
    gt: a list of list of Relation
    res: a list of list of Relation
  """

  #TODO to know how to calculate the total recall and prec

  assert len(gt) == len(res)
  tot_prec = 0
  tot_recall = 0
  total = 0
  # print("evaluating result...")

  # for _gt, _res in tqdm(zip(gt, res)):
  # for _gt, _res in tqdm(zip(gt, res), total=len(gt), desc='eval'):
  idx, t = 0, len(gt) 
  for _gt, _res in zip(gt, res):
    idx += 1
    print('Eval %d/%d (%d%%)' % (idx, t, idx / t * 100), ' ' * 45, end='\r')
    corr = compare_rel(_gt, _res, cmp_blank)
    precision = corr / len(_res) if len(_res) != 0 else 0
    recall = corr / len(_gt) if len(_gt) != 0 else 0
    tot_prec += precision
    tot_recall += recall
    total += 1
  # print()
  
  precision = tot_prec / total
  recall = tot_recall / total
  # print("Test on %d instances. Precision: %.2f, Recall: %.2f" % (
  #   total, precision, recall))
  return precision, recall
def eval_relations ( gt : List [ List ] , res : List [ List ] , cmp_blank = True ) : #TODO to know how to calculate the total recall and prec assert len ( gt ) == len ( res ) tot_prec = 0 tot_recall = 0 total = 0 # print("evaluating result...") # for _gt, _res in tqdm(zip(gt, res)): # for _gt, _res in tqdm(zip(gt, res), total=len(gt), desc='eval'): idx , t = 0 , len ( gt ) for _gt , _res in zip ( gt , res ) : idx += 1 print ( 'Eval %d/%d (%d%%)' % ( idx , t , idx / t * 100 ) , ' ' * 45 , end = '\r' ) corr = compare_rel ( _gt , _res , cmp_blank ) precision = corr / len ( _res ) if len ( _res ) != 0 else 0 recall = corr / len ( _gt ) if len ( _gt ) != 0 else 0 tot_prec += precision tot_recall += recall total += 1 # print() precision = tot_prec / total recall = tot_recall / total # print("Test on %d instances. Precision: %.2f, Recall: %.2f" % ( #   total, precision, recall)) return precision , recall