I am defining a function
def update(dictionary,key,value):
dictionary[key] = value
# if i do print dictionary... it still shows the original value?
I want to update the input dictionary in the main call
So this is the main function i wrote:
def update_mapping(mapping_dict,check_word,solution_word):
#print "here "
#new_mapping_dict = {}
for i,ele in enumerate(check_word):
if mapping_dict.has_key(ele):
if mapping_dict[ele] == "*":
mapping_dict[ele] = solution_word[i]
print ele, solution_word
print mapping_dict,check_word,solution_word
Basically I am inputting a misspelled word and then misspelled word has some mapping..
I do that mapping in the dictionary..
Like
mapping_dict ={"a":"x"...."s":"*"...}
So all the known alphabets whose mapping have been found have a legit key value alphabet pairs..
for the alphabets for which I havent found the right mapping, I am replacing them with “*”
and I am finding them with some algorithm (inverted index)
And as i found those, I want to update my dictionary?
Your problem must be elsewhere – this works.