ting 0.3.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.travis.yml +13 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +235 -0
- data/LICENSE.txt +674 -0
- data/{README.rdoc → README.md} +43 -35
- data/Rakefile +28 -15
- data/TODO +16 -15
- data/examples/hello.rb +12 -12
- data/lib/ting.rb +36 -61
- data/lib/ting/conversion.rb +6 -5
- data/lib/ting/conversions.rb +88 -80
- data/lib/ting/conversions/hanyu.rb +5 -9
- data/lib/ting/converter.rb +30 -0
- data/lib/ting/data/comparison.csv +410 -410
- data/lib/ting/data/final.csv +12 -10
- data/lib/ting/data/initial.csv +8 -7
- data/lib/ting/data/paladiy.txt +421 -421
- data/lib/ting/data/rules.yaml +38 -27
- data/lib/ting/data/valid_pinyin.yaml +454 -453
- data/lib/ting/exception.rb +14 -17
- data/lib/ting/groundwork.rb +181 -177
- data/lib/ting/procable.rb +7 -0
- data/lib/ting/reader.rb +27 -0
- data/lib/ting/string.rb +0 -15
- data/lib/ting/tones.rb +65 -65
- data/lib/ting/tones/accents.rb +75 -69
- data/lib/ting/tones/ipa.rb +1 -1
- data/lib/ting/tones/no_tones.rb +7 -7
- data/lib/ting/tones/numbers.rb +25 -25
- data/lib/ting/tones/supernum.rb +1 -1
- data/lib/ting/version.rb +1 -1
- data/lib/ting/writer.rb +23 -0
- data/spec/jruby_csv_spec.rb +78 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/ting_spec.rb +19 -0
- data/test/test_comparison.rb +43 -35
- data/test/test_hanyu_coverage.rb +42 -37
- data/ting.gemspec +23 -0
- metadata +95 -71
- data/examples/cgiform/cgiform.rb +0 -24
- data/examples/cgiform/template.rhtml +0 -69
- data/lib/ting/support.rb +0 -19
data/ting.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
require File.expand_path('../lib/ting/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'ting'
|
6
|
+
gem.version = Ting::VERSION
|
7
|
+
gem.authors = [ 'Arne Brasseur' ]
|
8
|
+
gem.email = [ 'arne@arnebrasseur.net' ]
|
9
|
+
gem.homepage = 'http://github.com/github/ting'
|
10
|
+
gem.license = 'GPL-3.0'
|
11
|
+
gem.platform = Gem::Platform::RUBY
|
12
|
+
|
13
|
+
gem.description = %q{Ting can convert between various phonetic representations of Mandarin Chinese. It can also handle various representation of tones, so it can be used to convert pinyin with numbers to pinyin with tones.}
|
14
|
+
gem.summary = %q{A conversion library for Chinese transcription methods like Hanyu Pinyin, Bopomofo and Wade-Giles.}
|
15
|
+
|
16
|
+
gem.require_paths = %w[ lib ]
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.test_files = `git ls-files -- spec test`.split($/)
|
19
|
+
gem.extra_rdoc_files = %w[ README.md History.txt TODO ]
|
20
|
+
|
21
|
+
gem.add_development_dependency 'rake', '~> 10.1'
|
22
|
+
gem.add_development_dependency 'rspec', '~> 2.14'
|
23
|
+
end
|
metadata
CHANGED
@@ -1,100 +1,124 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ting
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 0
|
10
|
-
version: 0.3.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Arne Brasseur
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
-
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10.1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.14'
|
41
|
+
description: Ting can convert between various phonetic representations of Mandarin
|
42
|
+
Chinese. It can also handle various representation of tones, so it can be used to
|
43
|
+
convert pinyin with numbers to pinyin with tones.
|
44
|
+
email:
|
45
|
+
- arne@arnebrasseur.net
|
24
46
|
executables: []
|
25
|
-
|
26
47
|
extensions: []
|
27
|
-
|
28
|
-
|
29
|
-
- README.rdoc
|
48
|
+
extra_rdoc_files:
|
49
|
+
- README.md
|
30
50
|
- History.txt
|
31
51
|
- TODO
|
32
|
-
files:
|
52
|
+
files:
|
53
|
+
- ".gitignore"
|
54
|
+
- ".travis.yml"
|
55
|
+
- Gemfile
|
56
|
+
- Gemfile.lock
|
33
57
|
- History.txt
|
34
|
-
-
|
58
|
+
- LICENSE.txt
|
59
|
+
- README.md
|
35
60
|
- Rakefile
|
36
61
|
- TODO
|
37
|
-
-
|
62
|
+
- examples/hello.rb
|
63
|
+
- lib/ting.rb
|
64
|
+
- lib/ting/conversion.rb
|
38
65
|
- lib/ting/conversions.rb
|
39
|
-
- lib/ting/tones/supernum.rb
|
40
|
-
- lib/ting/tones/accents.rb
|
41
|
-
- lib/ting/tones/numbers.rb
|
42
|
-
- lib/ting/tones/ipa.rb
|
43
|
-
- lib/ting/tones/no_tones.rb
|
44
|
-
- lib/ting/tones/marks.rb
|
45
|
-
- lib/ting/version.rb
|
46
66
|
- lib/ting/conversions/hanyu.rb
|
47
|
-
- lib/ting/
|
48
|
-
- lib/ting/exception.rb
|
49
|
-
- lib/ting/conversion.rb
|
50
|
-
- lib/ting/string.rb
|
51
|
-
- lib/ting/support.rb
|
52
|
-
- lib/ting.rb
|
67
|
+
- lib/ting/converter.rb
|
53
68
|
- lib/ting/data/comparison.csv
|
54
69
|
- lib/ting/data/final.csv
|
55
70
|
- lib/ting/data/initial.csv
|
56
71
|
- lib/ting/data/paladiy.txt
|
57
|
-
- lib/ting/data/valid_pinyin.yaml
|
58
72
|
- lib/ting/data/rules.yaml
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
73
|
+
- lib/ting/data/valid_pinyin.yaml
|
74
|
+
- lib/ting/exception.rb
|
75
|
+
- lib/ting/groundwork.rb
|
76
|
+
- lib/ting/procable.rb
|
77
|
+
- lib/ting/reader.rb
|
78
|
+
- lib/ting/string.rb
|
79
|
+
- lib/ting/tones.rb
|
80
|
+
- lib/ting/tones/accents.rb
|
81
|
+
- lib/ting/tones/ipa.rb
|
82
|
+
- lib/ting/tones/marks.rb
|
83
|
+
- lib/ting/tones/no_tones.rb
|
84
|
+
- lib/ting/tones/numbers.rb
|
85
|
+
- lib/ting/tones/supernum.rb
|
86
|
+
- lib/ting/version.rb
|
87
|
+
- lib/ting/writer.rb
|
88
|
+
- spec/jruby_csv_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/ting_spec.rb
|
63
91
|
- test/test_comparison.rb
|
64
|
-
|
65
|
-
|
66
|
-
|
92
|
+
- test/test_hanyu_coverage.rb
|
93
|
+
- ting.gemspec
|
94
|
+
homepage: http://github.com/github/ting
|
95
|
+
licenses:
|
96
|
+
- GPL-3.0
|
97
|
+
metadata: {}
|
67
98
|
post_install_message:
|
68
|
-
rdoc_options:
|
69
|
-
|
70
|
-
- README.rdoc
|
71
|
-
require_paths:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
72
101
|
- lib
|
73
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
-
|
75
|
-
requirements:
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
76
104
|
- - ">="
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
version: "0"
|
82
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
|
-
requirements:
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
85
109
|
- - ">="
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
88
|
-
segments:
|
89
|
-
- 0
|
90
|
-
version: "0"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
91
112
|
requirements: []
|
92
|
-
|
93
113
|
rubyforge_project:
|
94
|
-
rubygems_version:
|
114
|
+
rubygems_version: 2.2.0
|
95
115
|
signing_key:
|
96
|
-
specification_version:
|
97
|
-
summary: A conversion library for Chinese transcription methods like Hanyu Pinyin,
|
98
|
-
|
99
|
-
|
116
|
+
specification_version: 4
|
117
|
+
summary: A conversion library for Chinese transcription methods like Hanyu Pinyin,
|
118
|
+
Bopomofo and Wade-Giles.
|
119
|
+
test_files:
|
120
|
+
- spec/jruby_csv_spec.rb
|
121
|
+
- spec/spec_helper.rb
|
122
|
+
- spec/ting_spec.rb
|
100
123
|
- test/test_comparison.rb
|
124
|
+
- test/test_hanyu_coverage.rb
|
data/examples/cgiform/cgiform.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
|
3
|
-
|
4
|
-
require 'cgi'
|
5
|
-
require 'erb'
|
6
|
-
|
7
|
-
$: << File.dirname(__FILE__)+'/../../lib'
|
8
|
-
require 'pinyin'
|
9
|
-
|
10
|
-
cgi=CGI.new("xhtml1")
|
11
|
-
|
12
|
-
params=cgi.params
|
13
|
-
begin
|
14
|
-
if params['pinyin'] && params['pinyin'] != '' && params['pinyin'] != []
|
15
|
-
@converted = Pinyin::Writer.new(params['to'], params['to_tone']) << (Pinyin::Reader.new(params['from'],params['from_tone']) << params['pinyin'].first)
|
16
|
-
end
|
17
|
-
rescue
|
18
|
-
cgi.out{$!.to_s}
|
19
|
-
cgi.out{params['pinyin'].inspect}
|
20
|
-
end
|
21
|
-
|
22
|
-
cgi.out("text/html; charset=utf-8") do
|
23
|
-
ERB.new(IO.read('template.rhtml')).result(binding)
|
24
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Ruby Pinyin CGIForm example</title>
|
5
|
-
<style type='text/css'>
|
6
|
-
body {
|
7
|
-
font-family: sans-serif;
|
8
|
-
}
|
9
|
-
|
10
|
-
div#wrap {
|
11
|
-
width: 40%;
|
12
|
-
margin: 0 auto;
|
13
|
-
}
|
14
|
-
|
15
|
-
table {
|
16
|
-
width: 100%;
|
17
|
-
}
|
18
|
-
div#converted_text {
|
19
|
-
border: 1px dotted #000;
|
20
|
-
}
|
21
|
-
|
22
|
-
textarea {
|
23
|
-
width: 100%;
|
24
|
-
height: 10em;
|
25
|
-
margin: 0 auto;
|
26
|
-
}
|
27
|
-
</style>
|
28
|
-
</head>
|
29
|
-
<body>
|
30
|
-
<div id='wrap'>
|
31
|
-
<h2>Pinyin example application</h2>
|
32
|
-
<h3>Enter some pinyin text and choose your format</h3>
|
33
|
-
<table>
|
34
|
-
<form method='post'>
|
35
|
-
<tr>
|
36
|
-
<td colspan='2'>
|
37
|
-
<textarea name='pinyin'><%=params['pinyin'].first if params['pinyin'] != []%></textarea>
|
38
|
-
</td>
|
39
|
-
</tr>
|
40
|
-
|
41
|
-
<tr><td>From</td><td>To</td></tr>
|
42
|
-
<% Pinyin::Conversions::All.each do |f|%>
|
43
|
-
<tr>
|
44
|
-
<td><input type='radio' name='from' value='<%=f%>'><%=f.capitalize%></input></td>
|
45
|
-
<td><input type='radio' name='to' value='<%=f%>'><%=f.capitalize%></input></td>
|
46
|
-
</tr>
|
47
|
-
<% end %>
|
48
|
-
<tr><td>From tone</td><td>To tone</td></tr>
|
49
|
-
<% Pinyin::Tones::All.each do |f|%>
|
50
|
-
<tr>
|
51
|
-
<td><input type='radio' name='from_tone' value='<%=f%>'><%=f.capitalize%></input></td>
|
52
|
-
<td><input type='radio' name='to_tone' value='<%=f%>'><%=f.capitalize%></input></td>
|
53
|
-
</tr>
|
54
|
-
<% end %>
|
55
|
-
<tr>
|
56
|
-
<td><input type='submit'></input></td>
|
57
|
-
<td> </td>
|
58
|
-
</tr>
|
59
|
-
</form>
|
60
|
-
</table>
|
61
|
-
<% if @converted %>
|
62
|
-
<h2>Converted:</h2>
|
63
|
-
<div id='converted_text'>
|
64
|
-
<%= @converted %>
|
65
|
-
</div>
|
66
|
-
<% end %>
|
67
|
-
</div>
|
68
|
-
</body>
|
69
|
-
</html>
|
data/lib/ting/support.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
def uchars
|
3
|
-
self.unpack('U*').map{|c| [c].pack('U')}
|
4
|
-
end
|
5
|
-
|
6
|
-
def camelcase
|
7
|
-
str = dup
|
8
|
-
str.gsub!(/(?:_+|-+)([a-z])/){ $1.upcase }
|
9
|
-
str.gsub!(/(\A|\s)([a-z])/){ $1 + $2.upcase }
|
10
|
-
str
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module Kernel
|
15
|
-
def returning(s)
|
16
|
-
yield(s)
|
17
|
-
s
|
18
|
-
end
|
19
|
-
end
|