Last active
March 13, 2017 22:30
-
-
Save johnstcn/54baa7be2e8832d4ee4a4dc8ebe05bca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import fileinput | |
notes = [' '] + ('A Bb B C C# D Eb E F F# G G#'.split() * 2) | |
chars = ' abcdefghijklmnopqrstuvwy' | |
mapping = dict(zip(chars, notes)) | |
def normalize(c): | |
return c.lower() | |
def char2tone(c): | |
return mapping.get(normalize(c), '') | |
def process(line): | |
return ''.join(map(char2tone, line)) | |
def main(): | |
for line in fileinput.input(): | |
print process(line) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment