import re


def expand_contractions(sentence, contraction_mapping):
    """Expand contractions in a data from file.

    Args:
        sentence (str): Sentence to be expanded.
        contraction_mapping (json): Object containing contractions map.
        
    Returns:
        str: Expanded version of the string.
    """
    contractions_pattern = re.compile('({})'.format('|'.join(contraction_mapping.keys())), 
                                      flags=re.IGNORECASE|re.DOTALL)
    def expand_match(contraction):
        match = contraction.group(0)
        first_char = match[0]
        expanded_contraction = contraction_mapping.get(match)\
                                if contraction_mapping.get(match)\
                                else contraction_mapping.get(match.lower())                       
        expanded_contraction = first_char+expanded_contraction[1:]
        return expanded_contraction
        
    expanded_sentence = contractions_pattern.sub(expand_match, sentence)
    return expanded_sentence