ruby-pinyin 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +10 -0
- data/README.markdown +21 -22
- data/lib/ruby-pinyin.rb +8 -79
- data/lib/ruby-pinyin/backend.rb +6 -0
- data/lib/ruby-pinyin/backend/mmseg.rb +89 -0
- data/lib/ruby-pinyin/backend/simple.rb +68 -0
- data/lib/ruby-pinyin/{Mandarin.dat → data/Mandarin.dat} +0 -0
- data/lib/ruby-pinyin/{Punctuations.dat → data/Punctuations.dat} +0 -0
- data/lib/ruby-pinyin/data/words.dat +175182 -0
- data/lib/ruby-pinyin/data/words.dic +175182 -0
- data/lib/ruby-pinyin/punctuation.rb +42 -0
- data/lib/ruby-pinyin/version.rb +1 -1
- metadata +27 -7
- data/MIT-LICENSE +0 -20
@@ -0,0 +1,42 @@
|
|
1
|
+
module PinYin
|
2
|
+
module Punctuation
|
3
|
+
|
4
|
+
class <<self
|
5
|
+
|
6
|
+
def regexp
|
7
|
+
return @regexp if @regexp
|
8
|
+
|
9
|
+
escaped_punctuations = punctuations.values.map {|v| "\\#{[v].pack('H*')}"}.join
|
10
|
+
@regexp = Regexp.new "([#{escaped_punctuations}]+)$"
|
11
|
+
@regexp
|
12
|
+
end
|
13
|
+
|
14
|
+
def [](code)
|
15
|
+
punctuations[code]
|
16
|
+
end
|
17
|
+
|
18
|
+
def include?(code)
|
19
|
+
punctuations.has_key?(code)
|
20
|
+
end
|
21
|
+
|
22
|
+
def punctuations
|
23
|
+
return @punctuations if @punctuations
|
24
|
+
|
25
|
+
@punctuations = {}
|
26
|
+
src = File.expand_path('../data/Punctuations.dat', __FILE__)
|
27
|
+
load_from src
|
28
|
+
|
29
|
+
@punctuations
|
30
|
+
end
|
31
|
+
|
32
|
+
def load_from(file)
|
33
|
+
File.readlines(file).map do |line|
|
34
|
+
from, to = line.split(/\s+/)
|
35
|
+
@punctuations[from] = to
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
data/lib/ruby-pinyin/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-pinyin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Xie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
-
dependencies:
|
11
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rmmseg-cpp
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.9
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.9
|
13
27
|
description: Pinyin is a romanization system (phonemic notation) of Chinese characters,
|
14
28
|
this gem helps you to convert Chinese characters into pinyin form.
|
15
29
|
email:
|
@@ -18,12 +32,18 @@ executables: []
|
|
18
32
|
extensions: []
|
19
33
|
extra_rdoc_files: []
|
20
34
|
files:
|
21
|
-
- lib/ruby-pinyin/
|
35
|
+
- lib/ruby-pinyin/backend.rb
|
36
|
+
- lib/ruby-pinyin/backend/mmseg.rb
|
37
|
+
- lib/ruby-pinyin/backend/simple.rb
|
38
|
+
- lib/ruby-pinyin/data/Mandarin.dat
|
39
|
+
- lib/ruby-pinyin/data/words.dat
|
40
|
+
- lib/ruby-pinyin/data/words.dic
|
41
|
+
- lib/ruby-pinyin/data/Punctuations.dat
|
22
42
|
- lib/ruby-pinyin/value.rb
|
23
|
-
- lib/ruby-pinyin/
|
43
|
+
- lib/ruby-pinyin/punctuation.rb
|
24
44
|
- lib/ruby-pinyin/version.rb
|
25
45
|
- lib/ruby-pinyin.rb
|
26
|
-
-
|
46
|
+
- LICENSE
|
27
47
|
- README.markdown
|
28
48
|
homepage: https://github.com/janx/ruby-pinyin
|
29
49
|
licenses:
|
@@ -45,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
65
|
version: '0'
|
46
66
|
requirements: []
|
47
67
|
rubyforge_project:
|
48
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.1.11
|
49
69
|
signing_key:
|
50
70
|
specification_version: 4
|
51
71
|
summary: Convert Chinese characters into pinyin.
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2012 Jan Xie
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|