Created
November 23, 2011 20:05
-
-
Save gschizas/1389742 to your computer and use it in GitHub Desktop.
Spell almost any email in NATO phonetic alphabet
This file contains 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/python | |
# -*- coding: utf-8 -*- | |
# inspired by a comment in http://redd.it/mmr8m | |
import sys | |
letters = {' ': 'space', | |
'a': 'alfa', 'b': 'bravo', 'c': 'charlie', 'd': 'delta', | |
'e': 'echo', 'f': 'foxtrot', 'g': 'golf', 'h': 'hotel', | |
'i': 'india', 'j': 'juliett', 'k': 'kilo', 'l': 'lima', | |
'm': 'mike', 'n': 'november', 'o': 'oscar', 'p': 'papa', | |
'q': 'quebec', 'r': 'romeo', 's': 'sierra', 't': 'tango', | |
'u': 'uniform', 'v': 'victor', 'w': 'whiskey', 'x': 'xray', | |
'y': 'yankee', 'z': 'zulu', | |
'@': 'at', '.': 'dot', '/': 'slash', ',': 'comma', | |
':': 'colon', ';': 'semicolon', '_': 'underscore', | |
'α': 'αστήρ', 'β': 'βύρων', 'γ': 'γατί', 'δ': 'δόξα', | |
'ε': 'ερμής', 'ζ': 'ζεύς', 'η': 'ηρώ', 'θ': 'θεά', | |
'ί': 'ίσκιος', 'κ': 'κενό', 'λ': 'λάμα', 'μ': 'μέλι', | |
'ν': 'ναός', 'ξ': 'ξέρξης', 'ο': 'οσμή', 'π': 'πέτρος', | |
'ρ': 'ρήγας', 'σ': 'σοφός', 'τ': 'τίγρης', 'ύ': 'ύμνος', | |
'φ': 'φωφώ', 'χ': 'χαρά', 'ψ': 'ψυχή', 'ω': 'ωμέγα', | |
'1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', | |
'6': 'six', '7': 'seven', '8': 'eight', '9': 'nine', '0': 'zero'} | |
if len(sys.argv) <= 1: | |
original_text = raw_input('word-->') | |
else: | |
original_text = sys.argv[1] | |
spelling = [] | |
for letter in original_text: | |
letter = letter.lower() | |
if letters.has_key(letter): | |
spelling.append(letters[letter]) | |
else: | |
spelling.append('*' + letter + '*') | |
print(original_text) | |
print(', '.join(spelling)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment