class SpellingAlphabet::Japanese

Word set for Japanese radiotelephony alphabet. based on:

無線局運用規則
別表第五号 通話表(第14条関係)
1.和文通話表  2.欧文通話表(数字は和文通話表)
http://law.e-gov.go.jp/htmldata/S25/S25F30901000017.html

Constants

LETTER_WORD
WORD_LETTER
WORD_TABLE

Public Class Methods

interpret(text) click to toggle source

Converts each word to the original letter.

# File lib/spelling_alphabet/japanese.rb, line 149
def self.interpret(text)
  text.split(" ").map {|w| WORD_LETTER.fetch(w, w)}.join("")
end
normalize(text) click to toggle source

Converts hiragana letters and small letters to katakana letters.

# File lib/spelling_alphabet/japanese.rb, line 130
def self.normalize(text)
  if text =~ /[a-z]+/
    text.upcase
  elsif text =~ /\w+/
    text
  else
    text.tr('ぁ-ん', 'ァ-ン').tr(
      'ァィゥェォヵヶッャュョヮ', 'アイウエオカケツヤユヨワ')
  end
end
spellout(text) click to toggle source

Converts each letter to the corresponding word.

# File lib/spelling_alphabet/japanese.rb, line 142
def self.spellout(text)
  text.delete(" ").chars.map do |c|
    LETTER_WORD.fetch(self.normalize(c), c)
  end.join(" ")
end