def microaverage(spans, beta=1.0):
    """Receive list of spans [(list_extracted, list_annotated), ... ] 
    and return the micro-average (precision, recall, F1)"""
    beta2 = beta ** 2
    sum_tp = 0
    sum_tp_fp = 0
    sum_tp_fn = 0
    for selected, relevants in spans:
        sum_tp += len(selected & relevants)
        sum_tp_fp += len(selected)
        sum_tp_fn += len(relevants)
    ma_precision = sum_tp / sum_tp_fp if sum_tp_fp > 0 else float('Inf')
    ma_recall = sum_tp / sum_tp_fn if sum_tp_fn > 0 else float('Inf')
    ma_f1 = (1 + beta2) * (ma_precision * ma_recall) / (beta2 *
        ma_precision + ma_recall)
    return ma_precision, ma_recall, ma_f1
