Skip to content

Instantly share code, notes, and snippets.

@jiaaro
Created February 17, 2012 21:30
Show Gist options
  • Save jiaaro/1855582 to your computer and use it in GitHub Desktop.
Save jiaaro/1855582 to your computer and use it in GitHub Desktop.
Dotsies
"""notes:
Vowels all touch the top center and bottom except "O" which touches outlines
the center.
This is to give visual cues about the top and bottom of the line.
Consonants designed to be small and visually oriented around the center dot
for the most common letters, and as frequency of usage goes down, the dot
patterns that are oriented around the center dot are used.
"""
dotsies = {
'a': '10000',
'b': '01000',
'c': '00100',
'd': '00010',
'e': '00001',
'f': '11000',
'g': '01100',
'h': '00110',
'i': '00011',
'j': '10100',
'k': '01010',
'l': '00101',
'm': '10010',
'n': '01001',
'o': '10001',
'p': '11100',
'q': '11010',
'r': '10110',
's': '01110',
't': '01101',
'u': '01011',
'v': '00111',
'w': '11001',
'x': '10101',
'y': '10011',
'z': '11110',
}
dotsies3 = {
'a': '10101',
'b': '10001',
'c': '01101',
'd': '11100',
'e': '11111',
'f': '01011',
'g': '10100',
'h': '01100',
'i': '10111',
'j': '11000',
'k': '10011',
'l': '00111',
'm': '10110',
'n': '01000',
'o': '11011',
'p': '00101',
'q': '10000',
'r': '00110',
's': '00010',
't': '00100',
'u': '11101',
'v': '11001',
'w': '11010',
'x': '00011',
'y': '01010',
'z': '00001',
}
# From wikipedia
letter_freq = {
'a': 8.167,
'b': 1.492,
'c': 2.782,
'd': 4.253,
'e': 12.702,
'f': 2.228,
'g': 2.015,
'h': 6.094,
'i': 6.966,
'j': 0.153,
'k': 0.772,
'l': 4.025,
'm': 2.406,
'n': 6.749,
'o': 7.507,
'p': 1.929,
'q': 0.095,
'r': 5.987,
's': 6.327,
't': 9.056,
'u': 2.758,
'v': 0.978,
'w': 2.360,
'x': 0.150,
'y': 1.974,
'z': 0.074,
}
def vowels(pattern):
return dict((k,v) for (k,v) in pattern.iteritems() if k in 'aeiou')
def consonants(pattern):
return dict((k,v) for (k,v) in pattern.iteritems() if k not in 'aeiou')
def avg_density(pattern):
freq_total = sum(letter_freq[l] for l in pattern.iterkeys())
freq = lambda letter: letter_freq[letter] / freq_total
density = lambda glyph: sum(int(px) for px in glyph)
return sum(freq(l) * density(g) for (l, g) in pattern.iteritems())
def print_densities(pattern):
def pr(label, density): print " ", (label + ":").ljust(20), density
pr('Average density', avg_density(pattern))
pr('Vowel density', avg_density(vowels(pattern)))
pr('Consonant density', avg_density(consonants(pattern)))
print "DOTSIES"
print_densities(dotsies)
print
print "DOTSIES 3"
print_densities(dotsies3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment