1 | #!/usr/bin/python2.6 |
---|
2 | |
---|
3 | """ |
---|
4 | Translate lists of space separated integers (magnitude less than 62) and print |
---|
5 | as strings of alphanumeric characters. This is useful mainly for some machine |
---|
6 | learning algorithms that only take string input. |
---|
7 | |
---|
8 | usage: %prog < int_seqs > strings |
---|
9 | """ |
---|
10 | |
---|
11 | from itertools import * |
---|
12 | |
---|
13 | import sys |
---|
14 | |
---|
15 | table = "012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" |
---|
16 | |
---|
17 | def main(): |
---|
18 | for line in sys.stdin: |
---|
19 | ints = [ int( f ) for f in line.split() ] |
---|
20 | if max( ints ) > len( table ): |
---|
21 | raise "Alphabet size too large!" |
---|
22 | print str.join( '', [ table[i] for i in ints ] ) |
---|
23 | |
---|
24 | if __name__ == "__main__": main() |
---|