def test_get_class_labels_domains(kwik_e_mart_nlp, all_train_queries): app_domains = list(kwik_e_mart_nlp.domains.keys()) unique_domain_labels = list( set( LabelMap.get_class_labels(TuneLevel.DOMAIN.value, all_train_queries))) assert all(domain in app_domains for domain in unique_domain_labels)
def test_label_map_intents(kwik_e_mart_nlp): kwik_e_mart_query_tree = kwik_e_mart_nlp.resource_loader.get_labeled_queries( ) label_map = LabelMap(kwik_e_mart_query_tree) for domain in label_map.domain_to_intent2id: intent2id = label_map.domain_to_intent2id[domain] for intent, idx in intent2id.items(): assert label_map.id2intent[domain][idx] == intent
def test_get_class_labels_domains_intents(kwik_e_mart_nlp, all_train_queries): nlp_domain_intent_labels = [] for domain in kwik_e_mart_nlp.domains: for intent in kwik_e_mart_nlp.domains[domain].intents: label = f"{domain}.{intent}" nlp_domain_intent_labels.append(label) unique_domain_intent_labels = list( set(LabelMap.get_class_labels(TUNE_LEVEL_INTENT, all_train_queries))) assert all(label in nlp_domain_intent_labels for label in unique_domain_intent_labels)
def test_label_map_domains(kwik_e_mart_nlp): kwik_e_mart_query_tree = kwik_e_mart_nlp.resource_loader.get_labeled_queries( ) label_map = LabelMap(kwik_e_mart_query_tree) for domain, idx in label_map.domain2id.items(): assert label_map.id2domain[idx] == domain