def test_update_count_of_word(self, word, update_dict, expected_results, expected_new_count): auto_complete = AutoComplete(words=WIKIPEDIA_WORDS, synonyms=SYNONYMS, full_stop_words=['bmw', 'alfa romeo']) if update_dict: new_count = auto_complete.update_count_of_word(**update_dict) assert expected_new_count == new_count assert expected_new_count == auto_complete.get_count_of_word( update_dict['word']) results = auto_complete.search(word, max_cost=2, size=4) print_results(locals()) assert expected_results == results
model = line['model'] count = line['count'] if make != model: #local_words = [model, '{}{}'.format(make,model)] # print(local_words) # while local_words: # word = local_words.pop() # if word not in words: words['{}{}'.format(make, model)] = {} # if make not in words: #words[make] = {} return words synonyms = { "alfa romeo 4c coupe": ["the alfa", "hello"], "bmw": ["beemer", "bimmer"] } words = get_words("autocomp.csv") autocomplete = AutoComplete(words=words, synonyms=synonyms) autocomplete.search(word='the ', max_cost=3, size=5) # %% auto_complete.update_count_of_word(word='toyota aygo', count=10000) autocomplete.get_count_of_word('toyota aygo') # %% # %%