Module: Pinyin

Defined in:
lib/pinyin/groundwork.rb,
lib/pinyin.rb,
lib/pinyin/tones.rb,
lib/pinyin/tones.rb,
lib/pinyin/exception.rb,
lib/pinyin/conversion.rb,
lib/pinyin/conversions.rb,
lib/pinyin/tones/numbers.rb,
lib/pinyin/tones/no_tones.rb,
lib/pinyin/conversions/hanyu.rb

Overview

Classes and constants used throughout the module

* Initial
* Final
* TonelessSyllable
* Syllable
* ILLEGAL_COMBINATIONS

Defined Under Namespace

Modules: Conversions, Tones Classes: Conversion, Converter, Final, Initial, ParseError, Reader, Syllable, Tone, TonelessSyllable, Writer

Constant Summary collapse

VERSION =
"0.1.4"
Error =

All exceptions arising from this module inherit from Pinyin::Error

Class.new StandardError
ILLEGAL_COMBINATIONS =

Some groups of initials and finals may not be combined This list is not exhaustive but is sufficient to resolve ambiguity

[               
 [Initial::Group_0, Final::Group_0],
 [Initial::Group_1, Final::Group_0],
 [Initial::Group_2, Final::Group_0],
 [Initial::Group_3, Final::Group_0],
 [Initial::Group_4, Final::Group_0],

 [Initial::Group_4, Final::Group_U],
 [Initial::Group_4, Final::Group_A],

 [Initial::Group_3, Final::Group_I],
 [Initial::Group_5, Final::Group_I],
 [Initial::Group_6, Final::Group_I],

 [Initial::Group_1, Final::Group_V],
 [Initial::Group_3, Final::Group_V],

 #2008.05.26 lo is also valid!
 #[Initial::Group_2, [Final::O]],  #Only bo, po, mo and fo are valid -o combinations
 [Initial::Group_3, [Final::O]],
 [Initial::Group_4, [Final::O]],
 [Initial::Group_5, [Final::O]],
 [Initial::Group_6, [Final::O]],

 [[Initial::Empty], [Final::Ong]] 
   # TODO: Ong is actually the same as Ueng, in Hanyu Pinyin : -ong or weng
]

Class Method Summary collapse

Class Method Details

.valid_combinationsObject

Yields a block for any valid initial/final pair



170
171
172
173
174
175
176
177
178
179
180
# File 'lib/pinyin/groundwork.rb', line 170

def valid_combinations
  require 'yaml'
  inp = YAML::load(IO.read(File.join(File.dirname(__FILE__), 'data', 'valid_pinyin.yaml')))
  inp.each do |final, initials|
    final = Final.const_get(final)
    initials.each do |initial, pinyin|
      initial = Initial.const_get(initial)
      yield(initial, final)
    end
  end
end