Wednesday, December 13, 2006

"""

Synchronize FireFox 2.0 and Microsoft Dictionaries
Author: Alex Dong
Email: $ python -c "'YWxleC5kb25nQGdtYWlsLmNvbQ==\n'.decode('base64')
Blog: http://thetruelight.blogspot.com/
License: GPL
ReadMe:
Please change the 'word_dict_path' and 'ff_dict_path' to point
them to your local directories.
"""

word_dict_path = 'c:/Documents and Settings/adong/Application Data/Microsoft/Proof/custom.dic'
ff_dict_path = 'C:/Documents and Settings/adong/Application Data/Mozilla/Firefox/Profiles/yl9sxfvv.default/persdict.dat'
wd = open(word_dict_path).readlines()
fd = open(ff_dict_path).readlines()

def merge(a, b):
c = [i for i in a]
for i in b:
if c.count(i)==0: c.append(i)
return c

l = merge(wd, fd)
l.sort()

def update(f, l):
fp = open(f, 'w')
fp.writelines(l)
fp.close()
update(word_dict_path, l)
update(ff_dict_path, l)

print "Updated %d entries"%((len(l)-len(wd)) + (len(l)-len(fd)))

No comments: