Is there any way to cancel initialize object class if there is an error occurs in Python?
class EntityRetrieval(object): def __init__(self, entity_kb_path: str): “”” Args entity_kb_path: path of entity knowledge base (string) which is json format “”” try: entity_kb = json.load(open(entity_kb_path,’r’)) except Exception as e: logging.error(e) # Don’t use entity type entity_dict = {} for entity_type, entities in entity_kb.items(): for entity_id, list_entity_strings in entities.items(): entity_dict[entity_id] = list_entity_strings Above is my ugly code. […]