Showing posts with label NATO-phonetic-alphabet. Show all posts
Showing posts with label NATO-phonetic-alphabet. Show all posts

Tuesday, September 11, 2012

Convert words and numbers to the NATO Phonetic Alphabet

By Vasudev Ram


In my previous post, AboutMyBrowser from SupportBee, I had mentioned the NATO Phonetic Alphabet, which I saw via this HN thread.

That gave me the idea to write a function in Python to let you convert alphabets to the NATO Phonetic Alphabet code. It's a simple one, but it can be used to print out your name, or your city, etc., in that code, to use while talking to someone on the phone, radio, etc.

Here is the Python program, nato_phonetic_alphabet.py:

# nato_phonetic_alphabet.py
# Convert alphabets to the NATO Phonetic Alphabet code
# See: http://en.wikipedia.org/wiki/NATO_phonetic_alphabet
# Author: Vasudev Ram - http://www.dancingbison.com
# Version: 0.1

a_to_n = {
 "A": "ALFA", "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": "XRAY",
 "Y": "YANKEE", "Z": "ZULU",
 "1": "ONE", "2": "TWO", "3": "THREE", "4": "FOUR",
 "5": "FIVE", "6": "SIX", "7": "SEVEN", "8": "EIGHT",
 "9": "NINE", "0": "ZERO",
}

def alphabet_to_nato(alphabet):
 """
 """
 global a_to_n
 assert len(alphabet) == 1
 assert type(alphabet) == type("A")
 if a_to_n.has_key(alphabet):
  return a_to_n[alphabet]
 else:
  return " "

def main():
 # Test alphabet_to_nato() with a few alphabets.
 for alphabet in ("A", "D", "I", "P", "X", "1", "4", "7", "0"):
  print alphabet, ": ", alphabet_to_nato(alphabet)
 # Test alphabet_to_nato() with a few person names.
 names = ("VASUDEV RAM", "JOHN DOE", "J RANDOM HACKER")
 for name in names:
  print name, ": ",
  for alphabet in name:
   print alphabet_to_nato(alphabet),
  print

if __name__ == "__main__":
 main()

# EOF: nato_phonetic_alphabet.py

And here is the test output from the program - it converts a few alphabets and digits to the code, and also a few person names, including that of yours truly :)

A :  ALFA
D :  DELTA
I :  INDIA
P :  PAPA
X :  XRAY
1 :  ONE
4 :  FOUR
7 :  SEVEN
0 :  ZERO
VASUDEV RAM :  VICTOR ALFA SIERRA UNIFORM DELTA ECHO VICTOR   ROMEO ALFA MIKE
JOHN DOE :  JULIET OSCAR HOTEL NOVEMBER   DELTA OSCAR ECHO
J RANDOM HACKER :  JULIET   ROMEO ALFA NOVEMBER DELTA OSCAR MIKE   HOTEL ALFA CH
ARLIE KILO ECHO ROMEO

I may use this function in the next release of PipeController, just as a fun example, after adding a few more features to it (PipeController, that is).

Enjoy.

- Vasudev Ram - Dancing Bison Enterprises

AboutMyBrowser.com from SupportBee

By Vasudev Ram


AboutMyBrowser.com from SupportBee is a new web site that lets you get information about your browser and operating system, just by visiting it.

It is an MVP (Minimal Viable Product) right now, i.e. an early version.

This Hacker News thread about AboutMyBrowser has got a lot of comments and is currently the top post on HN.

I tried AboutMyBrowser out. It worked okay from my desktop browser but not from my mobile browser.
Still, it's an interesting product and seems to fulfill a real need for support staff, because typically when non-technical users are asked for their browser and OS details to help debug a web app issue, they can't easily find that out. This tool was created for exactly that reason.

[ As an aside, a couple of comments on the HN thread link to these sites which I found interesting:

Large English Vocabulary Word Lists.

This could be useful for some applications that need to manipulate or use words, for any purpose. The comment which had the link gave an example of that, related to AboutMyBrowser, but there could be other uses.

The NATO phonetic alphabet.

This is the familiar code used by pilots, etc. E.g. ALPHA BRAVO DELTA ... to make clear the spelling of words over a radio call which may have transmission static. ]

- Vasudev Ram - Dancing Bison Enterprises