Class: UkrainianLatin::Uklatn_uk_Latn_DSTU_9112_B_uk
- Inherits:
-
Object
- Object
- UkrainianLatin::Uklatn_uk_Latn_DSTU_9112_B_uk
- Defined in:
- lib/uklatn.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize ⇒ Uklatn_uk_Latn_DSTU_9112_B_uk
constructor
A new instance of Uklatn_uk_Latn_DSTU_9112_B_uk.
- #transform(text) ⇒ Object
Constructor Details
#initialize ⇒ Uklatn_uk_Latn_DSTU_9112_B_uk
Returns a new instance of Uklatn_uk_Latn_DSTU_9112_B_uk.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/uklatn.rb', line 141 def initialize() @rx1 = /([ÁáÉéÍíÓóÚúÝý])/ @maps1 = [ {"Á"=>"Á","á"=>"á","É"=>"É","é"=>"é","Í"=>"Í","í"=>"í","Ó"=>"Ó","ó"=>"ó","Ú"=>"Ú","ú"=>"ú","Ý"=>"Ý","ý"=>"ý"}, ] @rx2 = /([Jj][Oo][Ww]|[Ss][Hh][Cc][Hh]|[CcGgKkSsZzUuOo][Hh]|[Yy][Ww]|[Ee][Hh][Ww]|[Jj][EeIiUuAa]|[Hh][Jj]|[A-GIK-PR-VYZa-gik-pr-vyz])|(?<=[Ss][Hh][Cc][Hh])([Jj]\u0027(?=[AaEeIiUu])|[Jj])|(?<=[CcGgKkSsZz][Hh])([Jj]\u0027(?=[AaEeIiUu])|[Jj])|(?<=[BCDFGKLMNPRSTVZbcdfgklmnprstvzv])([Jj]\u0027(?=[AaEeIiUu])|[Jj])|(\u0027[Jj](?![AaEeIiUu])|\u0027(?=[Jj])|[Jj])/ @maps2 = [ {"A"=>"А","a"=>"а","B"=>"Б","b"=>"б","V"=>"В","v"=>"в","GH"=>"Г","Gh"=>"Г","gH"=>"г","gh"=>"г","G"=>"Ґ","g"=>"ґ","D"=>"Д","d"=>"д","E"=>"Е","e"=>"е","JE"=>"Є","Je"=>"Є","jE"=>"є","je"=>"є","ZH"=>"Ж","Zh"=>"Ж","zH"=>"ж","zh"=>"ж","Z"=>"З","z"=>"з","Y"=>"И","y"=>"и","I"=>"І","i"=>"і","JI"=>"Ї","Ji"=>"Ї","jI"=>"ї","ji"=>"ї","KH"=>"Х","Kh"=>"Х","kH"=>"х","kh"=>"х","K"=>"К","k"=>"к","L"=>"Л","l"=>"л","M"=>"М","m"=>"м","N"=>"Н","n"=>"н","O"=>"О","o"=>"о","P"=>"П","p"=>"п","R"=>"Р","r"=>"р","SHCH"=>"Щ","SHCh"=>"Щ","SHcH"=>"Щ","SHch"=>"Щ","ShCH"=>"Щ","ShCh"=>"Щ","ShcH"=>"Щ","Shch"=>"Щ","sHCH"=>"щ","sHCh"=>"щ","sHcH"=>"щ","sHch"=>"щ","shCH"=>"щ","shCh"=>"щ","shcH"=>"щ","shch"=>"щ","SH"=>"Ш","Sh"=>"Ш","sH"=>"ш","sh"=>"ш","S"=>"С","s"=>"с","T"=>"Т","t"=>"т","U"=>"У","u"=>"у","F"=>"Ф","f"=>"ф","CH"=>"Ч","Ch"=>"Ч","cH"=>"ч","ch"=>"ч","C"=>"Ц","c"=>"ц","JU"=>"Ю","Ju"=>"Ю","jU"=>"ю","ju"=>"ю","JA"=>"Я","Ja"=>"Я","jA"=>"я","ja"=>"я","HJ"=>"Ь","Hj"=>"Ь","hJ"=>"ь","hj"=>"ь","JOW"=>"Ё","JOw"=>"Ё","JoW"=>"Ё","Jow"=>"Ё","jOW"=>"ё","jOw"=>"ё","joW"=>"ё","jow"=>"ё","UH"=>"Ў","Uh"=>"Ў","uH"=>"ў","uh"=>"ў","OH"=>"Ъ","Oh"=>"Ъ","oH"=>"ъ","oh"=>"ъ","YW"=>"Ы","Yw"=>"Ы","yW"=>"ы","yw"=>"ы","EHW"=>"Э","EHw"=>"Э","EhW"=>"Э","Ehw"=>"Э","eHW"=>"э","eHw"=>"э","ehW"=>"э","ehw"=>"э"}, {"J"=>"Ь","j"=>"ь","J'"=>"Ь","j'"=>"ь"}, {"J"=>"Ь","j"=>"ь","J'"=>"Ь","j'"=>"ь"}, {"J"=>"Ь","j"=>"ь","J'"=>"Ь","j'"=>"ь"}, {"'J"=>"Й","'j"=>"й","'"=>"’","J"=>"Й","j"=>"й"}, ] end |
Instance Method Details
#transform(text) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/uklatn.rb', line 156 def transform(text) text = text.unicode_normalize(:nfc) text = text.gsub(@rx1) do |m| next @maps1[0].fetch($1, $1) unless $1.nil? m end text = text.gsub(@rx2) do |m| next @maps2[4].fetch($5, $5) unless $5.nil? next @maps2[3].fetch($4, $4) unless $4.nil? next @maps2[2].fetch($3, $3) unless $3.nil? next @maps2[1].fetch($2, $2) unless $2.nil? next @maps2[0].fetch($1, $1) unless $1.nil? m end text = text.unicode_normalize(:nfc) end |