tibetan 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -4
- data/lib/tibetan/version.rb +1 -1
- data/lib/tibetan.rb +31 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a99a8e45fb7a5b6fed9a82889c461a1ceec66df63086ec14e6ae60c784ae3c3
|
4
|
+
data.tar.gz: ba0c75c246e09eea0ea54c4838854e419954c7b8aef1f3ed6edcd6b6beca3b80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9c5c6085a9feada4da87b7017efc377cf25bbe530d45834eaf84d5ba781229df1ddf8fc7be515a911a1d4556ec879740830a871212b6a9dfb648c60221b1c62
|
7
|
+
data.tar.gz: 8cf0da67912ae5beedb1a2eda338b8477816d4d1627328876cc5f4cdc3debb915a9912fbafed71de00f9d57be2800174f75bd03a4685f536fa36f6b2c900215d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Tibetan
|
1
|
+
# Tibetan -> Wylie
|
2
2
|
|
3
|
-
Romanization of Tibetan. It transliterates Tibetan text to the
|
3
|
+
Romanization of Tibetan. It transliterates Tibetan text to the Latin script using THL EWTS (Extended Wylie Transliteration Scheme).
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -27,12 +27,16 @@ require "tibetan"
|
|
27
27
|
And then
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
Tibetan.transliterate("བོད་སྐད་")
|
30
|
+
Tibetan.transliterate("བོད་སྐད་") # => "bod skad"
|
31
|
+
Tibetan.transliterate("༡༢༣") # => "123"
|
32
|
+
Tibetan.transliterate("༪") # => "0.5"
|
31
33
|
```
|
32
34
|
or
|
33
35
|
|
34
36
|
```ruby
|
35
|
-
Tibetan.t("བོད་སྐད་")
|
37
|
+
Tibetan.t("བོད་སྐད་") # => "bod skad"
|
38
|
+
Tibetan.t("༡༢༣") # => "123"
|
39
|
+
Tibetan.t("༪") # => "0.5"
|
36
40
|
```
|
37
41
|
|
38
42
|
## Development
|
data/lib/tibetan/version.rb
CHANGED
data/lib/tibetan.rb
CHANGED
@@ -123,13 +123,42 @@ module Tibetan
|
|
123
123
|
"ླྀ" => "ḷ",
|
124
124
|
"ཹ" => "ḹ",
|
125
125
|
}
|
126
|
+
|
127
|
+
CONSONANTS = %w(ཀ ཁ ག ང ཅ ཆ ཇ ཉ ཏ ཐ ད ན པ ཕ བ མ ཙ ཚ ཛ ཝ ཞ ཟ འ ཡ ར ལ ཤ ས ཧ)
|
128
|
+
SUBSCRIPTS = %w(ྐ ྑ ྒ ྔ ྕ ྖ ྗ ྙ ྟ ྠ ྡ ྣ ྤ ྥ ྦ ྨ ྩ ྪ ྫ ྭ ྮ ྯ ྰ ྱ ྲ ླ ྴ ྶ ྷ)
|
129
|
+
VOWELS = %w(ྸ ི ུ ེ ོ a)
|
130
|
+
SEP = "་"
|
131
|
+
DEFAULT_VOWEL = "a"
|
126
132
|
|
127
133
|
class << self
|
128
134
|
def transliterate(string="", to=:tibetan)
|
135
|
+
string = string.to_s
|
136
|
+
|
137
|
+
# Split long phrase into small parts and transliterate separately
|
138
|
+
if string.split(SEP).size > 1
|
139
|
+
string = string.split(SEP).map do |str|
|
140
|
+
transliterate(str)
|
141
|
+
end.join(SEP)
|
142
|
+
end
|
143
|
+
|
144
|
+
insert_default_vowel!(string)
|
145
|
+
|
129
146
|
character_table = Module.const_get(to.to_s.capitalize)::CHARACTER_TABLE
|
130
|
-
string.to_s.gsub(/#{Regexp.union(character_table.keys).source}/i, character_table)
|
147
|
+
string.to_s.gsub(/#{Regexp.union(character_table.keys).source}/i, character_table)
|
131
148
|
end
|
132
149
|
alias_method :t, :transliterate
|
133
|
-
end
|
134
150
|
|
151
|
+
def insert_default_vowel!(string="")
|
152
|
+
# 1. after subscript
|
153
|
+
if (string.chars & VOWELS).empty?
|
154
|
+
index = string.rindex(/#{SUBSCRIPTS.join('|')}/)
|
155
|
+
string = string.insert(index+1, DEFAULT_VOWEL) unless index.nil?
|
156
|
+
end
|
157
|
+
# 2. after consonant, if not added in 1st step
|
158
|
+
if (string.chars & VOWELS).empty? && (string.chars & CONSONANTS).any?
|
159
|
+
index = string.size > 2 ? 1 : 0
|
160
|
+
string = string.insert(index+1, DEFAULT_VOWEL) unless index.nil?
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
135
164
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tibetan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rovetz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|