Skip to content

Update phonetic.py #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 40 additions & 35 deletions python3/phonetic.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
#!/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
```
"""

__author__ = ['Sunka Labree']
__date__ = ['2021.10.14 -> 2021.10.27']
# Imports sys.argv
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',
}
# Creates a dictionary
dicti = {'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. | --**', '1': 'One (Pronounce as Wun) | *----',
'2': 'Two (Pronounce as Too) | **---', '3': 'Three (Pronounce as Tree) | ***--',
'4': 'Four (Pronounce as Fower | ****-', '5': 'Five (Pronounce as Fife) | *****',
'6': 'Six (Pronounce as Six) | -****', '7': 'Seven (Pronounce as Sevun)| --***',
'8': 'Eight (Pronounce as Ait) | ---**', '9': 'Nine (Pronounce as Niner) | ----*',
'0': 'Zero (Pronounce as Zeero) | -----','A': 'Alpha | *-', 'A': '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()
# Checks if user has input words
if len(sys.argv) < -1:
user_input = sys.argv[-1]
else:
user_input = input('Enter Letters and Numbers to Translate: ')
# Translates given letters to NATO
for letter in user_input:
translation = dicti.get(letter)
print(letter, translation, sep='\t')