Serializing tabular data in ruby -- is map, flatten, hash the correct approach?
Feedback:


Instead of ||= lambda { ... }.call, you can use ||= begin ... end
Instead of Hash[*arr] you can use arr.to_h in Ruby 2.0+
You don't need to convert everything to a hash if you just want to use it for .map later -- [[1, 2], [3, 4]].map { |k, v| k + v } #=> [3, 7]
Instead of .map { ... }.flatten(1), you can use .flat_map { ... }
If you won't be using a variable in a block, you can use _ instead, like .map { |key, _| key }


I rewrote the code to be like what I'd code it today.

require 'yaml'

def do_it(raw)
  map = raw["v_eng"].split.zip(raw["v_jap"].split)

  raw.select do |k, _|
    k.size == 1
  end.flat_map do |pre, japs|
    map.zip(japs.split).map do |(post, _), jap|
      [pre + post, jap] unless jap == '_'
    end.compact
  end.to_h
end

want = {"katakana"=&gt;{"Ka"=&gt;"カ", "Ki"=&gt;"キ", "Ku"=&gt;"ク", "Ke"=&gt;"ケ", "Ko"=&gt;"コ", "Sa"=&gt;"サ", "Si"=&gt;"シ", "Su"=&gt;"ス", "Se"=&gt;"セ", "So"=&gt;"ソ", "Ta"=&gt;"タ", "Ti"=&gt;"チ", "Tu"=&gt;"ツ", "Te"=&gt;"テ", "To"=&gt;"ト", "Na"=&gt;"ナ", "Ni"=&gt;"ニ", "Nu"=&gt;"ヌ", "Ne"=&gt;"ネ", "No"=&gt;"ノ", "Ha"=&gt;"ハ", "Hi"=&gt;"ヒ", "Hu"=&gt;"フ", "He"=&gt;"ヘ", "Ho"=&gt;"ホ", "Ma"=&gt;"マ", "Mi"=&gt;"ミ", "Mu"=&gt;"ム", "Me"=&gt;"メ", "Mo"=&gt;"モ", "Ya"=&gt;"ヤ", "Yu"=&gt;"ユ", "Yo"=&gt;"ヨ", "Ra"=&gt;"ラ", "Ri"=&gt;"リ", "Ru"=&gt;"ル", "Re"=&gt;"レ", "Ro"=&gt;"ロ", "Wa"=&gt;"ワ", "Wi"=&gt;"ヰ", "We"=&gt;"ヱ", "Wo"=&gt;"ヲ"}, "hiragana"=&gt;{"ka"=&gt;"か", "ki"=&gt;"き", "ku"=&gt;"く", "ke"=&gt;"け", "ko"=&gt;"こ", "sa"=&gt;"さ", "si"=&gt;"し", "su"=&gt;"す", "se"=&gt;"せ", "so"=&gt;"そ", "ta"=&gt;"た", "ti"=&gt;"ち", "tu"=&gt;"つ", "te"=&gt;"て", "to"=&gt;"と", "na"=&gt;"な", "ni"=&gt;"に", "nu"=&gt;"ぬ", "ne"=&gt;"ね", "no"=&gt;"の", "ha"=&gt;"は", "hi"=&gt;"ひ", "hu"=&gt;"ふ", "he"=&gt;"へ", "ho"=&gt;"ほ", "ma"=&gt;"ま", "mi"=&gt;"み", "mu"=&gt;"む", "me"=&gt;"め", "mo"=&gt;"も", "ya"=&gt;"や", "yu"=&gt;"ゆ", "yo"=&gt;"よ", "ra"=&gt;"ら", "ri"=&gt;"り", "ru"=&gt;"る", "re"=&gt;"れ", "ro"=&gt;"ろ", "wa"=&gt;"わ", "wi"=&gt;"ゐ", "we"=&gt;"ゑ", "wo"=&gt;"を"}}

raw = YAML.load_file 'japanese.dic'

p do_it(raw["katakana"]) == want["katakana"] #=&gt; true
p do_it(raw["hiragana"]) == want["hiragana"] #=&gt; true


Hope that helps. Let me know if you want any other clarification(s) in a comment below.