def extract_metadata_from_query_results(query_results):
    """
    Given a Sparql query result, extract nationality, gender and birthdate
    :param query_results:
    :return:
    """
    if query_results["results"]["bindings"]:
        raw_metadata = query_results["results"]["bindings"][0]
        gender = raw_metadata['gender']['value'].lower()
        birth_date = raw_metadata['birthdate']['value']
        if "nationality_dbp" in raw_metadata.keys():
            nationality = raw_metadata['nationality_dbp']['value'].lower()
        elif "nationality_dbo" in raw_metadata.keys():
            nationality = raw_metadata['nationality_dbo']['value'].lower()
        else:
            nationality = ""
        return birth_date, gender, nationality
    else:
        raise ValueError