Module: PinYin
- Defined in:
- lib/ruby-pinyin.rb,
lib/ruby-pinyin/util.rb,
lib/ruby-pinyin/value.rb,
lib/ruby-pinyin/backend.rb,
lib/ruby-pinyin/version.rb,
lib/ruby-pinyin/punctuation.rb,
lib/ruby-pinyin/backend/mmseg.rb,
lib/ruby-pinyin/backend/simple.rb
Defined Under Namespace
Modules: Backend, Punctuation, Util
Classes: Value
Constant Summary
collapse
- VERSION =
'0.4.0'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.backend ⇒ Object
Returns the value of attribute backend.
9
10
11
|
# File 'lib/ruby-pinyin.rb', line 9
def backend
@backend
end
|
Class Method Details
.abbr(str, except_lead = false, except_english = true) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/ruby-pinyin.rb', line 25
def abbr(str, except_lead=false, except_english=true)
result = ""
of_string(str).each_with_index do |word, i|
w = (except_lead && i == 0) || (except_english && word.english?) ? word : word[0]
result << w
end
result
end
|
.of_character(str) ⇒ Object
16
17
18
19
|
# File 'lib/ruby-pinyin.rb', line 16
def of_character(str)
char = str.first
backend.get_readings(char)
end
|
.permlink(str, sep = '-') ⇒ Object
21
22
23
|
# File 'lib/ruby-pinyin.rb', line 21
def permlink(str, sep='-')
of_string(str).join(sep)
end
|
.romanize(str, tone = nil, include_punctuations = false) ⇒ Object
Also known as:
of_string
11
12
13
|
# File 'lib/ruby-pinyin.rb', line 11
def romanize(str, tone=nil, include_punctuations=false)
backend.romanize(str, tone, include_punctuations)
end
|
.sentence(str, tone = nil) ⇒ Object
34
35
36
|
# File 'lib/ruby-pinyin.rb', line 34
def sentence(str, tone=nil)
of_string(str, tone, true).join(' ')
end
|