lib/gimchi/pronouncer.rb in gimchi-0.2.0 vs lib/gimchi/pronouncer.rb in gimchi-0.2.1
- old
+ new
@@ -5,21 +5,21 @@
# Partial implementation of Korean pronouncement pronunciation rules specified in
# http://http://www.korean.go.kr/
# @private
class Pronouncer
private
- def initialize gimchi
- @gimchi = gimchi
- @pconfig = gimchi.config[:pronouncer]
+ def initialize pconfig, structure
+ @pconfig = pconfig
+ @structure = structure
end
def pronounce! str, options = {}
@sequence = @pconfig[:transformation][
"sequence_for_#{options[:each_char] ? '1' : '2'}".to_sym] - options[:except]
# Dissecting
- @chars = str.each_char.map { |c| @gimchi.kchar(c) rescue c }
+ @chars = str.each_char.map { |c| Gimchi.kchar(c) rescue c }
@orig_chars = @chars.dup
# Padding
@chars.each { |c| pad c }
@@ -84,16 +84,16 @@
c.jungsung = 'ㅡ' if c.jungsung.nil?
end
# shortcut
def fortis_map
- @gimchi.config[:structure][:fortis_map]
+ @structure[:fortis_map]
end
# shortcut
def double_consonant_map
- @gimchi.config[:structure][:double_consonant_map]
+ @structure[:double_consonant_map]
end
# 제5항: ‘ㅑ ㅒ ㅕ ㅖ ㅘ ㅙ ㅛ ㅝ ㅞ ㅠ ㅢ’는 이중 모음으로 발음한다.
# 다만 1. 용언의 활용형에 나타나는 ‘져, 쪄, 쳐’는 [저, 쩌, 처]로 발음한다.
# 다만 3. 자음을 첫소리로 가지고 있는 음절의 ‘ㅢ’는 [ㅣ]로 발음한다.
@@ -297,10 +297,10 @@
'피읖' => '피읍',
'히읗' => '히읏'}
word = @kc.to_s + @next_kc.to_s
if map.keys.include? word
- new_char = @gimchi.kchar(map[word].scan(/./mu)[1])
+ new_char = Gimchi.kchar(map[word].scan(/./mu)[1])
@next_kc.chosung = new_char.chosung
@next_kc.jongsung = new_char.jongsung
true
end