ting 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d7dbea414f62b23124a52f7eb9be4fed2997b92
4
- data.tar.gz: 1e179823cb2b4c37c17642d1afe165993ccb0489
3
+ metadata.gz: 832c9fb34c5415f06ee7a3c11063930e377ba9cf
4
+ data.tar.gz: 599204c5cec9e06962568922c4c477dd868911ba
5
5
  SHA512:
6
- metadata.gz: 5aad8f773d7731e222ea7c4c6324af8742954480b9258673a2a6e442b689bbed5b4e8bedbbbcfe058672a6d66782d37ea14be7457cff3a5581cce42e693f16ea
7
- data.tar.gz: 35ead7e81254b5294d7bce9c8dcaca965d661780e02702762060e5ab3dd6f15b863909f698627afa8cc6366de8d5941a118507fc59fb8306509d2a461f0927fd
6
+ metadata.gz: c35bc7b3cd2a40edb9fa89fe00089a1d3791eb640600a17b7de419beaa902e8047c20d24dda3d9fdb11346eeca7b9ecee3688d7010949edfabdc14a16187d11a
7
+ data.tar.gz: eb3868c3100089e6b9d55e71a7cb0d2f157a7a67ccf81e660422e285954897c3c09b3dd970a9264492823a762b64fdcd7a247fe84bd54ffed041dd1f78dce6c5
@@ -1,12 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.1
5
- - 2.2.5
6
- - 2.3.4
7
- - 2.4.2
8
- - jruby
3
+ - ruby-2.0.0
4
+ - ruby-2.1.1
5
+ - ruby-2.2.5
6
+ - ruby-2.3.4
7
+ - ruby-2.4.2
9
8
  - ruby-head
9
+ - jruby-9.1.9.0
10
10
  - jruby-head
11
11
  matrix:
12
12
  allow_failures:
@@ -0,0 +1,24 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
3
+
4
+ <!-- (this space deliberately left blank) -->
5
+ <!-- ### Added -->
6
+ <!-- ### Changed -->
7
+ <!-- ### Removed -->
8
+ <!-- ### Fixed -->
9
+
10
+ ## [Unreleased]
11
+
12
+ ## [0.11.0] - released 2017-11-06
13
+
14
+ ### Changed
15
+ - Make `Ting.pretty_tones` work with bopomofo
16
+ - Correct name of Palladius (Cyrilic transcription)
17
+ - Add missing IPA finals
18
+ - Change Palladius transcription of "hui" to хуэй
19
+
20
+ ### Added
21
+ - `bin/ting_table` script
22
+
23
+ [Unreleased]: https://github.com/lambdaisland/uri/compare/v0.11.0...HEAD
24
+ [0.11.0]: https://github.com/plexus/ting/compare/v0.11.0...v0.10.0
data/README.md CHANGED
@@ -10,6 +10,10 @@ to pinyin with tones.
10
10
  Hanyu Pinyin, Bopomofo, Wade-Giles, Tongyong Pinyin
11
11
  and International Phonetic Alphabet (IPA) are supported.
12
12
 
13
+ ## INSTALL
14
+
15
+ * gem install ting
16
+
13
17
  ## SYNOPSIS
14
18
 
15
19
  To parse your strings create a `Reader` object. Ting.reader() takes two
@@ -74,7 +78,7 @@ Generate IPA
74
78
  # => "iou˧˩˧ pʰeŋ˧˥ ts˥˩ yɛn˧˥ faŋ˥˥ lai˧˥"
75
79
  ````
76
80
 
77
- Since this is such a common use case, a convenience method to add diacritics to pinyin.
81
+ Since this is such a common use case, a convenience method exists to add diacritics to pinyin.
78
82
 
79
83
  ````ruby
80
84
  Ting.pretty_tones "wo3 ai4 ni3"
@@ -82,22 +86,24 @@ Since this is such a common use case, a convenience method to add diacritics to
82
86
  ````
83
87
 
84
88
  Note that syllables need to be separated by spaces, feeding "peng2you3" to the parser
85
- does not work. The `String#pretty_tones` method does handle these things a bit more gracefully.
89
+ does not work. The `Ting.pretty_tones(string)` method does handle these things a bit more gracefully.
86
90
 
87
91
  If you need to parse input that does not conform, consider using a regexp to scan for valid
88
- syllables, then feed the syllables to the parser one by one. Have a look at `#pretty_tones` for
89
- an example of how to do this.
92
+ syllables, then feed the syllables to the parser one by one. Have a look at `Ting.pretty_tones` for
93
+ an example of how to do this, but note that it does not support special cases like erhua
94
+ (wanr2 = wan2 er) or non-standard Pinyin syllables like 嗯/"ń" or 呣/"ḿ" (which appear in the official
95
+ Unicode data and some textbooks).
90
96
 
91
- ## REQUIREMENTS
97
+ ### ting_table
92
98
 
93
- * none, Ting uses nothing but Ruby
99
+ The `ting_table` script will spit out a CSV table of all syllables and formats Ting knows about. Useful if you want to do conversion in other languages.
94
100
 
95
- ## INSTALL
101
+ ## REQUIREMENTS
96
102
 
97
- * gem install ting
103
+ * none, Ting uses nothing but Ruby
98
104
 
99
105
  ## LICENSE
100
106
 
101
- Copyright (c) 2007-2014, Arne Brasseur. (http://www.arnebrasseur.net)
107
+ Copyright (c) 2007-2017, Arne Brasseur. (http://www.arnebrasseur.net)
102
108
 
103
109
  Available as Free Software under the GPLv3 License, see LICENSE.txt for details
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
4
+
5
+ require 'ting'
6
+ require 'csv'
7
+
8
+ zhuyin = Ting.writer(:zhuyin, :marks)
9
+ pinyin = Ting.writer(:hanyu, :accents)
10
+ pinyin2 = Ting.writer(:hanyu, :numbers)
11
+
12
+ writers = [
13
+ [:hanyu, :numbers],
14
+ [:hanyu, :accents],
15
+ [:ipa, :ipa],
16
+ [:tongyong, :accents],
17
+ [:wadegiles, :supernum],
18
+ [:zhuyin, :marks],
19
+ [:palladius, :no_tones]
20
+ ].map {|args| Ting.writer(*args)}
21
+
22
+
23
+ Ting.all_syllables do |s|
24
+ puts CSV.generate { |csv|
25
+ csv.puts writers.map {|w| w.call(s) }
26
+ }
27
+ end
@@ -52,13 +52,13 @@ module Ting
52
52
 
53
53
 
54
54
  def pretty_tones(string)
55
- string.gsub('u:','ü').gsub(/[A-Za-züÜ]{1,5}\d/) do |syll|
55
+ string.gsub('u:','ü').gsub(/[A-Za-züÜ]{1,7}\d?/) do |syll|
56
56
  SYLLABLE_CACHE[syll]
57
57
  end
58
58
  end
59
59
 
60
60
  def bpmf(string)
61
- string.gsub('u:','ü').scan(/[A-Za-züÜ]{1,5}\d/).map do |m|
61
+ string.gsub('u:','ü').scan(/[A-Za-züÜ]{1,7}\d?/).map do |m|
62
62
  Ting.writer(:zhuyin, :marks).(
63
63
  Ting.reader(:hanyu, :numbers).(m.downcase)
64
64
  )
@@ -2,11 +2,11 @@
2
2
  "hanyu","i","a","o","e",,"ai","ei","ao","ou","an","en","ang","eng","ong",,"i","ia",,"ie",,"iao","iu","ian","in","iang","ing","u","ua","uo","uai","ui","uan","un","uang",,"ü","üe","üan","ün","iong"
3
3
  "hanyu_standalone",,"a","o","e","ê","ai","ei","ao","ou","an","en","ang","eng",,"er","yi","ya","yo","ye","yai","yao","you","yan","yin","yang","ying","wu","wa","wo","wai","wei","wan","wen","wang","weng","yu","yue","yuan","yun","yong"
4
4
  "hanyu_no_abbrev","i","a","o","e",,"ai","ei","ao","ou","an","en","ang","eng","ong",,"i","ia","io","ie","iai","iao","iou","ian","ien","iang","ieng","u","ua","uo","uai","uei","uan","uen","uang","ueng","ü","üe","üan","üen","iong"
5
- "ipa",,"a","ɔ","ə",,"ai","ei","au","ou","an","en","aŋ","eŋ","ʊŋ","aɻ","i",,,"iɛ",,,"iou","iɛn","ɪn",,"iŋ","u",,"uɔ",,"uei","uan",,,"ueŋ","y","yuɛ","yɛn","yn","yʊŋ"
5
+ "ipa",,"a","ɔ","ə","ɛ","ai","ei","au","ou","an","en","aŋ","eŋ","ʊŋ","aɻ","i","ja","jɔ","iɛ","jai̯","jau̯","iou","iɛn","ɪn","jaŋ","iŋ","u","wa","uɔ","wai̯","uei","uan","wən","waŋ","ueŋ","y","yuɛ","yɛn","yn","yʊŋ"
6
6
  "tongyong","ih","a","o","e",,"ai","ei","ao","ou","an","en","ang","eng","ong",,"i","ia",,"ie",,"iao","iou","ian","in","iang","ing","u","ua","uo","uai","uei","uan","un","uang",,"yu","yue","yuan","yun","yong"
7
7
  "tongyong_standalone",,"a","o","e","ê","ai","ei","ao","ou","an","en","ang","eng",,"er","yi","ya","yo","ye","yai","yao","you","yan","yin","yang","ying","wu","wa","wo","wai","wei","wan","wun","wang","wong","yu","yue","yuan","yun","yong"
8
8
  "wadegiles","ih","a","o","e",,"ai","ei","ao","ou","an","en","ang","eng","ung","erh","i","ia",,"ieh",,"iao","iu","ien","in","iang","ing","u","ua","uo","uai","ui","uan","un","uang",,"ü","üeh","üan","ün","iung"
9
- "wadegiles_standalone",,,,,,,,,,,,,,,,,"ya","yo","yeh","yai","yao","yu","yan","yin","yang","ying","wu","wa","wo","wai","wei","wan","wen","wang","weng","yü","yüeh","yüan","yün","yung"
9
+ "wadegiles_standalone",,,,,"?",,,,,,,,,,,,"ya","yo","yeh","yai","yao","yu","yan","yin","yang","ying","wu","wa","wo","wai","wei","wan","wen","wang","weng","yü","yüeh","yüan","yün","yung"
10
10
  "zhuyin",,"ㄚ","ㄛ","ㄜ","ㄝ","ㄞ","ㄟ","ㄠ","ㄡ","ㄢ","ㄣ","ㄤ","ㄥ","ㄨㄥ","ㄦ","ㄧ","ㄧㄚ","ㄧㄛ","ㄧㄝ","ㄧㄞ","ㄧㄠ","ㄧㄡ","ㄧㄢ","ㄧㄣ","ㄧㄤ","ㄧㄥ","ㄨ","ㄨㄚ","ㄨㄛ","ㄨㄞ","ㄨㄟ","ㄨㄢ","ㄨㄣ","ㄨㄤ","ㄨㄥ","ㄩ","ㄩㄝ","ㄩㄢ","ㄩㄣ","ㄩㄥ"
11
- "palladin","и","а","о","э",,"ай","эй","ао","оу","ань","энь","ан","эн","ун","эр","и","я","ё","е","яй","яо","ю","янь","инь","ян","ин","у","уа","уо","уай","уй","уaнь","унь","уaн","вэн","юй","юэ","юaнь","юнь","юн"
12
- "palladin_standalone",,,,,,,,,,,,,,"вэн",,,,,,,,,,,,,,"ва","во","вай","вэй","вaнь","вэнь","вaн",,,,,
11
+ "palladius","и","а","о","э",,"ай","эй","ао","оу","ань","энь","ан","эн","ун","эр","и","я","ё","е","яй","яо","ю","янь","инь","ян","ин","у","уа","уо","уай","уй","уaнь","унь","уaн","вэн","юй","юэ","юaнь","юнь","юн"
12
+ "palladius_standalone",,,,,"?",,,,,,,,,"вэн",,,,,,,,,,,,,,"ва","во","вай","вэй","вaнь","вэнь","вaн",,,,,
@@ -5,4 +5,4 @@
5
5
  "tongyong",,"b","p","m","f","d","t","n","l","g","k","h","j","c","s","jh","ch","sh","r","z","c","s"
6
6
  "wadegiles",,"p","p`","m","f","t","t`","n","l","k","k`","h","ch","ch`","hs","ch","ch`","sh","j","ts","ts`","s"
7
7
  "zhuyin",,"ㄅ","ㄆ","ㄇ","ㄈ","ㄉ","ㄊ","ㄋ","ㄌ","ㄍ","ㄎ","ㄏ","ㄐ","ㄑ","ㄒ","ㄓ","ㄔ","ㄕ","ㄖ","ㄗ","ㄘ","ㄙ"
8
- "palladin",,"б","п","м","ф","д","т","н","л","г","к","х","цзи","ци","си","чж","ч","ш","ж","цзы","цы","сы"
8
+ "palladius",,"б","п","м","ф","д","т","н","л","г","к","х","цзи","ци","си","чж","ч","ш","ж","цзы","цы","сы"
@@ -23,7 +23,7 @@ wadegiles:
23
23
  tongyong:
24
24
  - match: feng
25
25
  subst: fong
26
- palladin:
26
+ palladius:
27
27
  - match: (ц|цз|с)ы([^и].{0,2})
28
28
  subst: \1\2
29
29
  - match: (ц|цз|с)ыи
@@ -33,6 +33,6 @@ palladin:
33
33
  - match: (ц|г|х|к|л|н|ж|чж|цз)уо
34
34
  subst: \1о
35
35
  - match: хуй
36
- subst: хой
36
+ subst: хуэй
37
37
  - match: цзюэ
38
38
  subst: цзюе
@@ -1,3 +1,3 @@
1
1
  module Ting
2
- VERSION = '0.10.0'
2
+ VERSION = '0.11.0'
3
3
  end
@@ -0,0 +1,11 @@
1
+ RSpec.describe 'palladius' do
2
+ let(:converter) { Ting.from(:hanyu, :numbers).to(:palladius, :no_tones) }
3
+
4
+ it 'should convert from Hanyu pinyin to Palladius' do
5
+ expect(converter.call('you3 peng2 zi4 yuan2 fang2 lai2')).to eql 'ю пэн цзы юaнь фан лай'
6
+ end
7
+
8
+ it 'avoids the word for "penis"' do
9
+ expect(converter.call('hui4')).to eql 'хуэй'
10
+ end
11
+ end
@@ -5,7 +5,7 @@ describe Ting do
5
5
  let(:pinyin) { 'dao4 ke3 dao4 fei1 chang2 dao4'.force_encoding('UTF-8') }
6
6
  let(:bopomofo) { 'ㄉㄠˋ ㄎㄜˇ ㄉㄠˋ ㄈㄟ ㄔㄤˊ ㄉㄠˋ'.force_encoding('UTF-8') }
7
7
 
8
- it 'should convert from Hany Pinyin to Bopomofo' do
8
+ it 'should convert from Hanyu Pinyin to Bopomofo' do
9
9
  expect(Ting.from(:hanyu, :numbers).to(:zhuyin, :marks).convert(pinyin)).to eq(bopomofo)
10
10
  end
11
11
 
@@ -16,4 +16,9 @@ describe Ting do
16
16
  it 'should respect capitalization' do
17
17
  expect(Ting.from(:hanyu, :numbers).to(:hanyu, :accents).convert('Bei3 jing1')).to eq('Běi jīng')
18
18
  end
19
+
20
+ it 'should parse syllables correctly' do
21
+ expect(Ting.pretty_tones('wo3 de peng2you3 hen3 zhuang4')).to eq('wǒ de péngyǒu hěn zhuàng')
22
+ expect(Ting.bpmf('wo3 de peng2you3 hen3 zhuang4')).to eq('ㄨㄛˇ ㄉㄜ˙ ㄆㄥˊ ㄧㄡˇ ㄏㄣˇ ㄓㄨㄤˋ')
23
+ end
19
24
  end
@@ -13,9 +13,11 @@ Gem::Specification.new do |gem|
13
13
  gem.summary = %q{A conversion library for Chinese transcription methods like Hanyu Pinyin, Bopomofo and Wade-Giles.}
14
14
 
15
15
  gem.require_paths = %w[ lib ]
16
+ gem.bindir = 'bin'
16
17
  gem.files = `git ls-files`.split($/)
17
18
  gem.test_files = `git ls-files -- spec test`.split($/)
18
19
  gem.extra_rdoc_files = %w[ README.md History.txt TODO ]
20
+ gem.executables << 'ting_table'
19
21
 
20
22
  gem.add_development_dependency 'rake', '~> 10.1'
21
23
  gem.add_development_dependency 'rspec', '~> 2.14'
metadata CHANGED
@@ -1,61 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arne Brasseur
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-23 00:00:00.000000000 Z
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: rake
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
19
  version: '10.1'
19
- name: rake
20
- prerelease: false
21
20
  type: :development
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '10.1'
27
27
  - !ruby/object:Gem::Dependency
28
+ name: rspec
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - "~>"
31
32
  - !ruby/object:Gem::Version
32
33
  version: '2.14'
33
- name: rspec
34
- prerelease: false
35
34
  type: :development
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.14'
41
41
  - !ruby/object:Gem::Dependency
42
+ name: test-unit
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
45
  - - ">="
45
46
  - !ruby/object:Gem::Version
46
47
  version: '0'
47
- name: test-unit
48
- prerelease: false
49
48
  type: :development
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: 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.
55
+ description: Ting can convert between various phonetic representations of Mandarin
56
+ Chinese. It can also handle various representation of tones, so it can be used to
57
+ convert pinyin with numbers to pinyin with tones.
56
58
  email:
57
59
  - arne@arnebrasseur.net
58
- executables: []
60
+ executables:
61
+ - ting_table
59
62
  extensions: []
60
63
  extra_rdoc_files:
61
64
  - README.md
@@ -64,6 +67,7 @@ extra_rdoc_files:
64
67
  files:
65
68
  - ".gitignore"
66
69
  - ".travis.yml"
70
+ - CHANGELOG.md
67
71
  - Gemfile
68
72
  - Gemfile.lock
69
73
  - History.txt
@@ -71,6 +75,7 @@ files:
71
75
  - README.md
72
76
  - Rakefile
73
77
  - TODO
78
+ - bin/ting_table
74
79
  - code_of_conduct.md
75
80
  - examples/hello.rb
76
81
  - lib/ting.rb
@@ -100,6 +105,7 @@ files:
100
105
  - lib/ting/version.rb
101
106
  - lib/ting/writer.rb
102
107
  - spec/jruby_csv_spec.rb
108
+ - spec/palladius_spec.rb
103
109
  - spec/spec_helper.rb
104
110
  - spec/ting_spec.rb
105
111
  - test/test_comparison.rb
@@ -110,7 +116,7 @@ homepage: https://github.com/plexus/ting
110
116
  licenses:
111
117
  - GPL-3.0
112
118
  metadata: {}
113
- post_install_message:
119
+ post_install_message:
114
120
  rdoc_options: []
115
121
  require_paths:
116
122
  - lib
@@ -125,13 +131,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
131
  - !ruby/object:Gem::Version
126
132
  version: '0'
127
133
  requirements: []
128
- rubyforge_project:
129
- rubygems_version: 2.4.8
130
- signing_key:
134
+ rubyforge_project:
135
+ rubygems_version: 2.6.13
136
+ signing_key:
131
137
  specification_version: 4
132
- summary: A conversion library for Chinese transcription methods like Hanyu Pinyin, Bopomofo and Wade-Giles.
138
+ summary: A conversion library for Chinese transcription methods like Hanyu Pinyin,
139
+ Bopomofo and Wade-Giles.
133
140
  test_files:
134
141
  - spec/jruby_csv_spec.rb
142
+ - spec/palladius_spec.rb
135
143
  - spec/spec_helper.rb
136
144
  - spec/ting_spec.rb
137
145
  - test/test_comparison.rb