from utils import connect_vector_db, load_collection, convert_query, clean_query, load_json def routing_query(query, path_stop_words, path_define): data = load_json(path_define) entities = [ele['word'] for ele in data] domains = [ele['domain'] for ele in data] mapping_dict = {item['word']: item['domain'] for item in data} query_cleaned = clean_query(path_stop_words, query) for word in query_cleaned: for key, value in mapping_dict.items(): if word == key: collection_name = value print("index choose: ", collection_name) return collection_name if __name__ == "__main__": query = """Không được vượt xe trong những trường hợp nào?""" path_stop_words = '/root/minhnq88/DATN/milvus/searching/define_routing/vi_stopword.txt' path_define = '/root/minhnq88/DATN/milvus/searching/define_routing/define.json' routing_query(query, path_stop_words, path_define)