wylie 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/wylie +14 -0
- data/lib/wylie.rb +3 -0
- data/lib/wylie/constants.rb +133 -0
- data/lib/wylie/converter.rb +195 -0
- data/lib/wylie/version.rb +3 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/wylie/converter_spec.rb +90 -0
- data/spec/wylie_spec.rb +7 -0
- data/wylie.gemspec +24 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7c9f4b2676358a7ecc1443ed56d4fa2703984b7a
|
4
|
+
data.tar.gz: 6fce293975bd45577ab4b1e96a2688de9cc1bbc4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a4201de31cef97e8a8eb4196256a14a0c1d8e28db1f58a88fe03e79760abbead871134b7ac071e078662f859b62918c8a07ae2d6913385d5c3e85ff6ad566528
|
7
|
+
data.tar.gz: 26783a9a67670e64bb9de1a2a4095d475b3b603182ce7102eaeab296c25b42e903cf0f90567dcd111433fe3d3f49999c424d7c0ebaa778b309e1152c7fa27297
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 BlueVajra
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Wylie
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'wylie'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install wylie
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
You can just write `converter = Wylie::Converter.new` and then `converter.tibetan("bsgrubs ")`. the output will be a Tibetan encoded string.
|
22
|
+
|
23
|
+
You can also use a helper in a rails app to convert wylie in your views
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
module TibetanHelper
|
27
|
+
|
28
|
+
TIBETAN_CONVERTER = Wylie::Converter.new
|
29
|
+
|
30
|
+
def to_tibetan(phrase)
|
31
|
+
TIBETAN_CONVERTER.tibetan(phrase)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it ( http://github.com/bluevajra/wylie/fork )
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/wylie
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'wylie'
|
4
|
+
|
5
|
+
# from command line in tibetan dictionary dir
|
6
|
+
# bundle exec gems/wylie/bin/wylie "dam pa'i chos"
|
7
|
+
|
8
|
+
# puts STDIN.read
|
9
|
+
|
10
|
+
puts
|
11
|
+
puts "Translating: #{ARGV[0]}"
|
12
|
+
puts
|
13
|
+
puts Wylie::Converter.new.tibetan(ARGV[0])
|
14
|
+
puts
|
data/lib/wylie.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
module Wylie
|
2
|
+
CONSONANTS = {
|
3
|
+
"kh" => [["\u0f41"], ["\u0f91"]],
|
4
|
+
"k" => [["\u0f40"], ["\u0f90"]],
|
5
|
+
"g" => [["\u0f42"], ["\u0f92"]],
|
6
|
+
"gh" => [["\u0f42", "\u0fb7"], ["\u0f92", "\u0fb7"]],
|
7
|
+
"g+h" => [["\u0f42", "\u0fb7"], ["\u0f92", "\u0fb7"]],
|
8
|
+
"ng" => [["\u0f44"], ["\u0f94"]],
|
9
|
+
"c" => [["\u0f45"], ["\u0f95"]],
|
10
|
+
"ch" => [["\u0f46"], ["\u0f96"]],
|
11
|
+
"j" => [["\u0f47"], ["\u0f97"]],
|
12
|
+
"ny" => [["\u0f49"], ["\u0f99"]],
|
13
|
+
"T" => [["\u0f4a"], ["\u0f9a"]],
|
14
|
+
"-t" => [["\u0f4a"], ["\u0f9a"]],
|
15
|
+
"Th" => [["\u0f4b"], ["\u0f9b"]],
|
16
|
+
"-th" => [["\u0f4b"], ["\u0f9b"]],
|
17
|
+
"D" => [["\u0f4c"], ["\u0f9c"]],
|
18
|
+
"-d" => [["\u0f4c"], ["\u0f9c"]],
|
19
|
+
"Dh" => [["\u0f4c", "\u0fb7"], ["\u0f9c", "\u0fb7"]],
|
20
|
+
"D+h" => [["\u0f4c", "\u0fb7"], ["\u0f9c", "\u0fb7"]],
|
21
|
+
"-dh" => [["\u0f4c", "\u0fb7"], ["\u0f9c", "\u0fb7"]],
|
22
|
+
"-d+h" => [["\u0f4c", "\u0fb7"], ["\u0f9c", "\u0fb7"]],
|
23
|
+
"N" => [["\u0f4e"], ["\u0f9e"]],
|
24
|
+
"-n" => [["\u0f4e"], ["\u0f9e"]],
|
25
|
+
"t" => [["\u0f4f"], ["\u0f9f"]],
|
26
|
+
"th" => [["\u0f50"], ["\u0fa0"]],
|
27
|
+
"d" => [["\u0f51"], ["\u0fa1"]],
|
28
|
+
"dh" => [["\u0f51", "\u0fb7"], ["\u0fa1", "\u0fb7"]],
|
29
|
+
"d+h" => [["\u0f51", "\u0fb7"], ["\u0fa1", "\u0fb7"]],
|
30
|
+
"n" => [["\u0f53"], ["\u0fa3"]],
|
31
|
+
"p" => [["\u0f54"], ["\u0fa4"]],
|
32
|
+
"ph" => [["\u0f55"], ["\u0fa5"]],
|
33
|
+
"b" => [["\u0f56"], ["\u0fa6"]],
|
34
|
+
"bh" => [["\u0f56", "\u0fb7"], ["\u0fa6", "\u0fb7"]],
|
35
|
+
"b+h" => [["\u0f56", "\u0fb7"], ["\u0fa6", "\u0fb7"]],
|
36
|
+
"m" => [["\u0f58"], ["\u0fa8"]],
|
37
|
+
"ts" => [["\u0f59"], ["\u0fa9"]],
|
38
|
+
"tsh" => [["\u0f5a"], ["\u0faa"]],
|
39
|
+
"dz" => [["\u0f5b"], ["\u0fab"]],
|
40
|
+
"dzh" => [["\u0f5b", "\u0fb7"], ["\u0fab", "\u0fb7"]],
|
41
|
+
"dz+h" => [["\u0f5b", "\u0fb7"], ["\u0fab", "\u0fb7"]],
|
42
|
+
"w" => [["\u0f5d"], ["\u0fad"]],
|
43
|
+
"zh" => [["\u0f5e"], ["\u0fae"]],
|
44
|
+
"z" => [["\u0f5f"], ["\u0faf"]],
|
45
|
+
"'" => [["\u0f60"], ["\u0fb0"]],
|
46
|
+
"\u2018" => [["\u0f60"], ["\u0fb0 "]], # typographic quotes
|
47
|
+
"\u2019" => [["\u0f60"], ["\u0fb0"]],
|
48
|
+
"y" => [["\u0f61"], ["\u0fb1"]],
|
49
|
+
"r" => [["\u0f62"], ["\u0fb2"]],
|
50
|
+
"l" => [["\u0f63"], ["\u0fb3"]],
|
51
|
+
"sh" => [["\u0f64"], ["\u0fb4"]],
|
52
|
+
"Sh" => [["\u0f65"], ["\u0fb5"]],
|
53
|
+
"-sh" => [["\u0f65"], ["\u0fb6"]],
|
54
|
+
"s" => [["\u0f66"], ["\u0fb7"]],
|
55
|
+
"h" => [["\u0f67"], ["\u0fb8"]],
|
56
|
+
"W" => [["\u0f5d"], ["\u0fba"]],
|
57
|
+
"Y" => [["\u0f61"], ["\u0fbb"]],
|
58
|
+
"R" => [["\u0f6a"], ["\u0fbc"]],
|
59
|
+
"f" => [["\u0f55"], ["\u0f39"]],
|
60
|
+
"v" => [["\u0f56"], ["\u0f39"]],
|
61
|
+
}
|
62
|
+
|
63
|
+
VOWELS = {
|
64
|
+
"a" => [["\u0F68"], ["\u0FB8"]],
|
65
|
+
"A" => [["\u0f71"]],
|
66
|
+
"i" => [["\u0f72"]],
|
67
|
+
"I" => [["\u0f71", "\u0f72"]],
|
68
|
+
"u" => [["\u0f74"]],
|
69
|
+
"U" => [["\u0f71", "\u0f74"]],
|
70
|
+
"e" => [["\u0f7a"]],
|
71
|
+
"ai" => [["\u0f7b"]],
|
72
|
+
"o" => [["\u0f7c"]],
|
73
|
+
"au" => [["\u0f7d"]],
|
74
|
+
"-i" => [["\u0f80"]],
|
75
|
+
"-I" => [["\u0f71", "\u0f80"]]
|
76
|
+
}
|
77
|
+
|
78
|
+
SANSKRIT_VOWELS = {
|
79
|
+
"r-i" => [["\u0fb2", "\u0f80"]],
|
80
|
+
"r-I" => [["\u0fb2", "\u0f71", "\u0f80"]],
|
81
|
+
"l-i" => [["\u0fb3", "\u0f80"]],
|
82
|
+
"l-I" => [["\u0fb3", "\u0f71", "\u0f80"]]
|
83
|
+
}
|
84
|
+
|
85
|
+
COMPLEX_VOWELS = {
|
86
|
+
"r-i " => [["\u0f62", "\u0f80"], ["\u0fb2", "\u0f80"]],
|
87
|
+
"r-I " => [["\u0f62", "\u0f71", "\u0f80"], ["\u0fb2", "\u0f71", "\u0f80"]],
|
88
|
+
"l-i " => [["\u0f63", "\u0f80"], ["\u0fb3", "\u0f80"]],
|
89
|
+
"l-I " => [["\u0f63", "\u0f71", "\u0f80"], ["\u0fb3", "\u0f71", "\u0f80"]]
|
90
|
+
}
|
91
|
+
|
92
|
+
FINAL = {
|
93
|
+
"M" => [["\u0f7e"]], # anusvara / bindu / circle above / nga ro
|
94
|
+
"H" => [["\u0f7f"]], # visarga / rnam bcad
|
95
|
+
"~M`" => [["\u0f82"]], # crescent", bindu & nada
|
96
|
+
"~M" => [["\u0f83"]], # crescent & bindu
|
97
|
+
"?" => [["\u0f84"]], # halanta / srog med
|
98
|
+
"X" => [["\u0f37"]], # small circle under
|
99
|
+
"~X" => [["\u0f35"]], # small circle w/ crescent under
|
100
|
+
"^" => [["\u0f39}"]] # tsa-phru
|
101
|
+
}
|
102
|
+
|
103
|
+
OTHER = {
|
104
|
+
"0" => [["\u0f20"]],
|
105
|
+
"1" => [["\u0f21"]],
|
106
|
+
"2" => [["\u0f22"]],
|
107
|
+
"3" => [["\u0f23"]],
|
108
|
+
"4" => [["\u0f24"]],
|
109
|
+
"5" => [["\u0f25"]],
|
110
|
+
"6" => [["\u0f26"]],
|
111
|
+
"7" => [["\u0f27"]],
|
112
|
+
"8" => [["\u0f28"]],
|
113
|
+
"9" => [["\u0f29"]],
|
114
|
+
" " => [["\u0f0b"]],
|
115
|
+
"*" => [["\u0f0c"]],
|
116
|
+
"/" => [["\u0f0d"]],
|
117
|
+
"//" => [["\u0f0e"]],
|
118
|
+
";" => [["\u0f0f"]],
|
119
|
+
"|" => [["\u0f11"]],
|
120
|
+
"!" => [["\u0f08"]],
|
121
|
+
":" => [["\u0f14"]],
|
122
|
+
"_" => [[" "]],
|
123
|
+
"=" => [["\u0f34"]],
|
124
|
+
"<" => [["\u0f3a"]],
|
125
|
+
">" => [["\u0f3b"]],
|
126
|
+
"(" => [["\u0f3c"]],
|
127
|
+
")" => [["\u0f3d"]],
|
128
|
+
"@" => [["\u0f04"]],
|
129
|
+
"#" => [["\u0f05"]],
|
130
|
+
"$" => [["\u0f06"]],
|
131
|
+
"#" => [["\u0f07"]],
|
132
|
+
}
|
133
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
module Wylie
|
2
|
+
class Converter
|
3
|
+
def initialize(debug = false)
|
4
|
+
combined_characters = CONSONANTS.merge(VOWELS).merge(SANSKRIT_VOWELS).merge(FINAL).merge(OTHER)
|
5
|
+
|
6
|
+
@sorted_characters = combined_characters.sort_by do |key, value|
|
7
|
+
key.size
|
8
|
+
end.reverse.to_h
|
9
|
+
|
10
|
+
@vowels = VOWELS.merge(SANSKRIT_VOWELS)
|
11
|
+
@debug = debug
|
12
|
+
end
|
13
|
+
|
14
|
+
def tibetan(wylie)
|
15
|
+
wylie_syllables = wylie.split(" ")
|
16
|
+
tibetan_text = wylie_syllables.map do |syl|
|
17
|
+
tibetan_syllable(syl)
|
18
|
+
end
|
19
|
+
is_terminating_character?(wylie[-1]) ? ending = "" : ending = "་"
|
20
|
+
tibetan_text.join(@sorted_characters[" "][0].join) + ending
|
21
|
+
end
|
22
|
+
|
23
|
+
def tibetan_syllable(syl)
|
24
|
+
wylie_tokens = parse_syllable(syl)
|
25
|
+
transcribe_wylie(wylie_tokens)
|
26
|
+
end
|
27
|
+
|
28
|
+
def transcribe_wylie(tokens)
|
29
|
+
|
30
|
+
@new_stack = true
|
31
|
+
@preceeded_by_plus = false
|
32
|
+
|
33
|
+
tib_roles = tibetan_roles(tokens)
|
34
|
+
tib_tokens = []
|
35
|
+
|
36
|
+
pp tokens if @debug
|
37
|
+
pp tib_roles if @debug
|
38
|
+
|
39
|
+
tokens.each_with_index do |token, index|
|
40
|
+
|
41
|
+
if token == "+"
|
42
|
+
@preceeded_by_plus = true
|
43
|
+
next
|
44
|
+
end
|
45
|
+
|
46
|
+
subjoined_characters = ["root_sub", "foot"]
|
47
|
+
|
48
|
+
if VOWELS.include?(token)
|
49
|
+
if index == 0
|
50
|
+
tib_tokens << @sorted_characters["a"][0].join
|
51
|
+
end
|
52
|
+
|
53
|
+
if token == "a"
|
54
|
+
next
|
55
|
+
end
|
56
|
+
@new_stack = true
|
57
|
+
elsif subjoined_characters.include?(tib_roles[index])
|
58
|
+
@new_stack = false
|
59
|
+
elsif @preceeded_by_plus
|
60
|
+
@new_stack = false
|
61
|
+
else
|
62
|
+
@new_stack = true
|
63
|
+
end
|
64
|
+
|
65
|
+
@preceeded_by_plus = false
|
66
|
+
|
67
|
+
if is_new_stack?
|
68
|
+
tib_tokens << @sorted_characters[token][0].join
|
69
|
+
else
|
70
|
+
tib_tokens << @sorted_characters[token][1].join
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
tib_tokens.flatten.join
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def is_new_stack?
|
80
|
+
@new_stack
|
81
|
+
end
|
82
|
+
|
83
|
+
def is_preceeded_by_plus?
|
84
|
+
@preceeded_by_plus
|
85
|
+
end
|
86
|
+
|
87
|
+
def is_vowel?(char)
|
88
|
+
@vowels.has_key?(char)
|
89
|
+
end
|
90
|
+
|
91
|
+
def is_head_letter?(char)
|
92
|
+
["s", "r", "l"].include?(char)
|
93
|
+
end
|
94
|
+
|
95
|
+
def is_foot_letter?(char)
|
96
|
+
["y", "r", "l"].include?(char)
|
97
|
+
end
|
98
|
+
|
99
|
+
def is_prefix?(char)
|
100
|
+
["g", "d", "b", "m", "'"].include?(char)
|
101
|
+
end
|
102
|
+
|
103
|
+
def is_terminating_character?(char)
|
104
|
+
["g", "/"].include?(char)
|
105
|
+
end
|
106
|
+
|
107
|
+
def parse_syllable(syl)
|
108
|
+
tib = syl
|
109
|
+
x = true
|
110
|
+
tib_string = []
|
111
|
+
@y = false
|
112
|
+
|
113
|
+
while x == true
|
114
|
+
|
115
|
+
@sorted_characters.each do |key, value|
|
116
|
+
@y = true
|
117
|
+
if tib.start_with?(key)
|
118
|
+
tib_string << key
|
119
|
+
tib.slice!(0..key.size-1)
|
120
|
+
@y = false
|
121
|
+
end
|
122
|
+
break if @y == false
|
123
|
+
end
|
124
|
+
|
125
|
+
# CHECKS FOR A + SYMBOL
|
126
|
+
if tib.match(/^[\+]/)
|
127
|
+
tib_string << "+"
|
128
|
+
tib.sub!(/\+/, "")
|
129
|
+
@y = false
|
130
|
+
end
|
131
|
+
|
132
|
+
x = false if @y == true
|
133
|
+
end
|
134
|
+
tib_string
|
135
|
+
end
|
136
|
+
|
137
|
+
def starts_with?(prefix)
|
138
|
+
prefix = prefix.to_s
|
139
|
+
self[0, prefix.length] == prefix
|
140
|
+
end
|
141
|
+
|
142
|
+
def tibetan_roles(tokens)
|
143
|
+
tib_roles = []
|
144
|
+
|
145
|
+
tokens.each_with_index do |token, index|
|
146
|
+
|
147
|
+
next_token = tokens[index+1]
|
148
|
+
next_next_token = tokens[index+2]
|
149
|
+
previous_token = tokens[index-1]
|
150
|
+
previous_role = tib_roles[index-1]
|
151
|
+
|
152
|
+
if index == 0
|
153
|
+
if is_vowel?(token)
|
154
|
+
tib_roles << "vowel"
|
155
|
+
elsif is_vowel?(next_token)
|
156
|
+
tib_roles << "root"
|
157
|
+
elsif is_foot_letter?(next_token) && is_vowel?(next_next_token)
|
158
|
+
tib_roles << "root"
|
159
|
+
elsif is_prefix?(token)
|
160
|
+
tib_roles << "pre"
|
161
|
+
elsif is_head_letter?(token)
|
162
|
+
tib_roles << "head"
|
163
|
+
else
|
164
|
+
tib_roles << "root"
|
165
|
+
end
|
166
|
+
else
|
167
|
+
if is_vowel?(token)
|
168
|
+
tib_roles << "vowel"
|
169
|
+
elsif is_vowel?(previous_token) || previous_role == "suf"
|
170
|
+
tib_roles << "suf"
|
171
|
+
elsif previous_role.include?("root") && is_foot_letter?(token)
|
172
|
+
tib_roles << "foot"
|
173
|
+
elsif previous_role == "head"
|
174
|
+
tib_roles << "root_sub"
|
175
|
+
elsif previous_role == "pre" && is_vowel?(next_token)
|
176
|
+
tib_roles << "root"
|
177
|
+
else
|
178
|
+
tib_roles << "head"
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
tib_roles
|
183
|
+
end
|
184
|
+
|
185
|
+
def show_unicode
|
186
|
+
pp CONSONANTS
|
187
|
+
pp VOWELS
|
188
|
+
pp SANSKRIT_VOWELS
|
189
|
+
pp COMPLEX_VOWELS
|
190
|
+
pp FINAL
|
191
|
+
pp OTHER
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Wylie
|
4
|
+
describe Converter do
|
5
|
+
|
6
|
+
context "converts single syllables tibetan," do
|
7
|
+
it "converts with 'a' vowels" do
|
8
|
+
converter = Converter.new
|
9
|
+
|
10
|
+
expect(converter.tibetan_syllable("ka")).to eq "ཀ"
|
11
|
+
expect(converter.tibetan_syllable("sha")).to eq "ཤ"
|
12
|
+
expect(converter.tibetan_syllable("la")).to eq "ལ"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "converts with 'i' vowels" do
|
16
|
+
converter = Converter.new
|
17
|
+
|
18
|
+
expect(converter.tibetan_syllable("ki")).to eq "ཀི"
|
19
|
+
expect(converter.tibetan_syllable("shi")).to eq "ཤི"
|
20
|
+
expect(converter.tibetan_syllable("hi")).to eq "ཧི"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "converts suffexes" do
|
24
|
+
converter = Converter.new
|
25
|
+
|
26
|
+
expect(converter.tibetan_syllable("bod")).to eq "བོད"
|
27
|
+
expect(converter.tibetan_syllable("ling")).to eq "ལིང"
|
28
|
+
expect(converter.tibetan_syllable("thun")).to eq "ཐུན"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "converts second suffexes" do
|
32
|
+
converter = Converter.new
|
33
|
+
|
34
|
+
expect(converter.tibetan_syllable("longs")).to eq "ལོངས"
|
35
|
+
expect(converter.tibetan_syllable("sings")).to eq "སིངས"
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
it "works with sanskrit dhi variations" do
|
40
|
+
converter = Converter.new
|
41
|
+
|
42
|
+
expect(converter.tibetan_syllable("dhi")).to eq "དྷི"
|
43
|
+
expect(converter.tibetan_syllable("Dhi")).to eq "ཌྷི"
|
44
|
+
expect(converter.tibetan_syllable("D+hi")).to eq "ཌྷི"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "works with other edge cases" do
|
48
|
+
converter = Converter.new
|
49
|
+
expect(converter.tibetan_syllable("longs")).to eq "ལོངས"
|
50
|
+
expect(converter.tibetan_syllable("puMsoH")).to eq "པུཾསོཿ"
|
51
|
+
expect(converter.tibetan_syllable("oM")).to eq "ཨོཾ"
|
52
|
+
expect(converter.tibetan_syllable("hUM")).to eq "ཧཱུཾ"
|
53
|
+
expect(converter.tibetan_syllable("d+hiH")).to eq "དྷིཿ"
|
54
|
+
expect(converter.tibetan_syllable("eShAMpatiSh+ThAH")).to eq "ཨེཥཱཾཔཏིཥྛཱཿ"
|
55
|
+
expect(converter.tibetan_syllable("hru'u")).to eq "ཧྲུའུ"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "works with multiple syllables" do
|
59
|
+
converter = Converter.new
|
60
|
+
|
61
|
+
expect(converter.tibetan("dam pa'i chos ")).to eq "དམ་པའི་ཆོས་"
|
62
|
+
expect(converter.tibetan("'jigs byed ")).to eq "འཇིགས་བྱེད་"
|
63
|
+
expect(converter.tibetan("snyam rtsom ")).to eq "སྙམ་རྩོམ་"
|
64
|
+
expect(converter.tibetan("bkris ")).to eq "བཀྲིས་"
|
65
|
+
expect(converter.tibetan("lo tsA ba ")).to eq "ལོ་ཙཱ་བ་"
|
66
|
+
expect(converter.tibetan("dzam+b+ha ")).to eq "ཛམྦྷ་"
|
67
|
+
expect(converter.tibetan("bsgrubs ")).to eq "བསྒྲུབས་"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "adds ending character if one doesn't exist for multiple syllables" do
|
71
|
+
converter = Converter.new
|
72
|
+
expect(converter.tibetan("snyam rtsom")).to eq "སྙམ་རྩོམ་"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "converts the .ya properly" do
|
76
|
+
pending
|
77
|
+
converter = Converter.new
|
78
|
+
expect(converter.tibetan("g.yo")).to eq "གཡོ"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "handles alternate final consonants" do
|
82
|
+
pending
|
83
|
+
converter = Converter.new
|
84
|
+
expect(converter.tibetan("gur guM")).to eq "གུར་གུཾ"
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
data/spec/wylie_spec.rb
ADDED
data/wylie.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wylie/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wylie"
|
8
|
+
spec.version = Wylie::VERSION
|
9
|
+
spec.authors = ["BlueVajra"]
|
10
|
+
spec.email = ["cory.leistikow@gmail.com"]
|
11
|
+
spec.summary = "Converts EWTS into Tibetan Unicode Characters"
|
12
|
+
spec.description = "See above"
|
13
|
+
spec.homepage = "https://github.com/BlueVajra/Wylie"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wylie
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- BlueVajra
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: See above
|
56
|
+
email:
|
57
|
+
- cory.leistikow@gmail.com
|
58
|
+
executables:
|
59
|
+
- wylie
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/wylie
|
71
|
+
- lib/wylie.rb
|
72
|
+
- lib/wylie/constants.rb
|
73
|
+
- lib/wylie/converter.rb
|
74
|
+
- lib/wylie/version.rb
|
75
|
+
- spec/spec_helper.rb
|
76
|
+
- spec/wylie/converter_spec.rb
|
77
|
+
- spec/wylie_spec.rb
|
78
|
+
- wylie.gemspec
|
79
|
+
homepage: https://github.com/BlueVajra/Wylie
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.2.2
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Converts EWTS into Tibetan Unicode Characters
|
103
|
+
test_files:
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
- spec/wylie/converter_spec.rb
|
106
|
+
- spec/wylie_spec.rb
|