def get_test_detect_intent_entity_drink_for_text(): intent = 'cancel_item_intent' test_tuples = [] sentity = SEntity() entity_list = sentity.list() drink_entity_id = entity_list['drink'] drinks = sentity.get(drink_entity_id)['drink']['entity'] size = "NA" size_synonym = "NA" for drink in drinks: drink_synonyms = drinks[drink] for drink_synonym in drink_synonyms: test_tuples.append((intent, drink, size, drink_synonym, size_synonym)) return test_tuples
def get_test_detect_intent_entity_drink_size_for_text(): intent = 'order_intent' test_tuples = [] sentity = SEntity() entity_list = sentity.list() drink_entity_id = entity_list['drink'] drinks = sentity.get(drink_entity_id)['drink']['entity'] size_entity_id = entity_list['size'] sizes = sentity.get(size_entity_id)['size']['entity'] for drink in drinks: drink_synonyms = drinks[drink] for size in sizes: size_synonyms = sizes[size] for drink_synonym in drink_synonyms: for size_synonym in size_synonyms: test_tuples.append( (intent, drink, size, drink_synonym, size_synonym)) return test_tuples
class EntityApp: def __init__(self): self.__sentity = SEntity() def create_entity(self): # Load the menu item menu_df = pd.read_csv("../input/CheeseCakeFactory-Menu.csv") value_synonym_map = {} for index, row in menu_df.iterrows(): menu_item = row['Dish Name'] value_synonym_map[menu_item] = [menu_item] response = self.__sentity.create("Menu", value_synonym_map, enable_fuzzy_extraction=True) print(response) # result = sentity.list() # print(result) def run(self): self.create_entity()
def __init__(self): self.__sentity = SEntity()
def google_entity_client(self): sentity = SEntity() return sentity