from typing import List
from typing import Dict
from typing import Any


def fix_annotations_format(data: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
    """Fix annotations format for a consistent dataset
    
    ### Parameters
    --------------
    **data**: (List[Dict[str, Any]]), required.
        List of Examples
    
    ### Returns
    -----------
    (List[Dict[str, Any]]): 
        List of Examples with corrected formatting
    """    
    for e in data:
        if 'meta' not in e:
            e['meta'] = {}
        if isinstance(e['meta'], list) or isinstance(e['meta'], str):
            e['meta'] = {
                'source': e['meta']
            }

        for s in e['spans']:
            if 'text' not in s:
                s['text'] = e['text'][s['start']:s['end']]
            s['label'] = s['label'].upper()
    return data