-
Notifications
You must be signed in to change notification settings - Fork 106
/
phonetic.py
executable file
·38 lines (32 loc) · 925 Bytes
/
phonetic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
__author__ = ['[Brandon Amos](http://bamos.github.io)']
__date__ = '2014.02.14'
"""
Obtain the NATO phonetic alphabet representation from short phrases.
```
$ phonetic.py github
g - golf
i - india
t - tango
h - hotel
u - uniform
b - bravo
```
"""
import sys
phonetic_table = {
'a': 'alpha', 'b': 'bravo', 'c': 'charlie', 'd': 'delta', 'e': 'echo',
'f': 'foxtrot', 'g': 'golf', 'h': 'hotel', 'i': 'india', 'j': 'juliet',
'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': 'x-ray',
'y': 'yankee', 'z': 'zulu',
}
for word in sys.argv[1:]:
for char in word:
char = char.lower()
if char not in phonetic_table:
print(char)
else:
print(char + ' - ' + phonetic_table[char])
print()