def extract_entity_types(line):
    """Extracts the entity type for an entity"""
    entity_types = []
    if "P31" in line["claims"]:
        for d in line["claims"]["P31"]:
            if "mainsnak" in d and "datavalue" in d["mainsnak"]:
                entity_types.append(d["mainsnak"]["datavalue"]["value"]["id"])
    return entity_types