from sys import argv, exit from abbr import load # produces insert-mode abbreviations commands for vim from abbr.txt if len(argv) != 2: exit(''' Syntax: %(prog)s <abbr.txt> You might do: %(prog)s <abbr.txt> > ~/.vimiab echo "map <Leader>a :source ~/.vimiab<CR>" >> ~/.vimrc Then you can open up a file, hit \a to turn on abbreviation mode, and start editing. '''.strip() % {'prog': argv[0]}) for k, v in sorted(load(argv[1]).items(), key=lambda (k, v): (len(k), k)): print 'iab %s %s' % (k, v)
import sys from abbr import load # produces dict file for pidgin from abbr.txt abbr = load(sys.argv[1]) for k, v in abbr.items(): print """ COMPLETE 1 CASE 0 BAD %s GOOD %s """ % (k, v)
import re import sys import urllib2 import abbr abs = dict([[x[1], x[0]] for x in abbr.load(sys.argv[1]).items()]) url = 'http://www.edict.com.hk/lexiconindex/frequencylists/words2000.htm' content = urllib2.urlopen(url) pattern = re.compile('target="Vocabulary">(.+?)</a>') for line in content.readlines(): match = pattern.search(line) if match: word = match.group(1).lower() if not abs.has_key(word): abs[word] = 'xxx' for k, v in sorted(abs.iteritems()): print '%s\t%s' % (v, k)