Skip to content

Instantly share code, notes, and snippets.

@vinc
Created October 20, 2014 19:54
Show Gist options
  • Select an option

  • Save vinc/63720159a932f731df8b to your computer and use it in GitHub Desktop.

Select an option

Save vinc/63720159a932f731df8b to your computer and use it in GitHub Desktop.
jamos_tables = [
%w(g gg n d dd r m b bb s ss - j jj c k t p h),
%w(a ae ya yae eo e yeo ye o wa wae oe yo u weo we wi yu eu yi i),
%w(- g gg gs n nj nh d l lg lm lb ls lt lp lh m b bs s ss ng j c k t p h)
]
transcoded_text = ARGF.read.split.map do |word|
syllables = word.scan(/[ptksmnljw]?[aeiou][n]?/)
unicodes = syllables.map do |syllable|
syllable.tr!('lj', 'ry')
jamos = [/n$/, /[wy]?[aeiou]$/, /\w/].map do |regexp|
syllable.slice!(regexp) || '-'
end.reverse
x, y, z = jamos.each_with_index.map do |jamo, i|
jamos_tables[i].index(jamo)
end
(588 * x) + (28 * y) + z + 44032
end
unicodes.map { |u| [u].pack('U') }.join
end.join(' ')
puts transcoded_text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment