Module: PinYin
- Defined in:
- lib/ruby-pinyin.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
Classes: Value
Constant Summary
collapse
- VERSION =
'0.3.0'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.backend ⇒ Object
Returns the value of attribute backend.
8
9
10
|
# File 'lib/ruby-pinyin.rb', line 8
def backend
@backend
end
|
Class Method Details
.abbr(str, except_lead = false, except_english = true) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/ruby-pinyin.rb', line 19
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
|
.permlink(str, sep = '-') ⇒ Object
15
16
17
|
# File 'lib/ruby-pinyin.rb', line 15
def permlink(str, sep='-')
of_string(str).join(sep)
end
|
.romanize(str, tone = nil, include_punctuations = false) ⇒ Object
Also known as:
of_string
10
11
12
|
# File 'lib/ruby-pinyin.rb', line 10
def romanize(str, tone=nil, include_punctuations=false)
backend.romanize(str, tone, include_punctuations)
end
|
.sentence(str, tone = nil) ⇒ Object
28
29
30
|
# File 'lib/ruby-pinyin.rb', line 28
def sentence(str, tone=nil)
of_string(str, tone, true).join(' ')
end
|