greeklish_iso843 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -2
- data/README.md +7 -11
- data/lib/greeklish_iso843/converter.rb +24 -19
- data/lib/greeklish_iso843/version.rb +1 -1
- 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: 07ec5fdb5be2bca43018f9afc095163e3f83db8ca2306efa4d00e57154a400cf
|
4
|
+
data.tar.gz: 4c367180883ffe24351544e5566a580ff38d500cc7a51c1b180a757bd4985483
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab641750790707f68e497156645459dac086bf068d517cc48cc4bb4774bf9e6bb3b8ae0314f90e0319a29403075c0ec17870c511fd94e0b222da6d2b4d7ed860
|
7
|
+
data.tar.gz: 4c5a6c023fb1a2c5c88ce15558dc43b8c5f7216a0eb673bd22973ac9166607b7042e49725dfea4669c50b42642cb61cd983643a1a201a92f3488e677fe3e42b9
|
data/CHANGELOG.md
CHANGED
@@ -7,10 +7,22 @@ The format is based on [Keep a Changelog][] and this project adheres to
|
|
7
7
|
|
8
8
|
## [Unreleased][]
|
9
9
|
|
10
|
-
## 0.
|
10
|
+
## [0.2.0][] - 2021-03-04
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Fix transliteration of `ευ` followed by a vowel or `β`, `γ`, `δ`, `ζ`, `λ`,
|
15
|
+
`μ`, `ν`, `ρ`. For example, `Ευάγγελος` used to be converted to `Efangelos`
|
16
|
+
and now it's `Evangelos`. `άνευ` remains `anef`.
|
17
|
+
- Use precompiled `Regexp` for replacements to speed things up.
|
18
|
+
[#1](https://github.com/agorf/greeklish_iso843/pull/1) by
|
19
|
+
[@iridakos](https://github.com/iridakos)
|
20
|
+
|
21
|
+
## 0.1.0 - 2021-03-03
|
11
22
|
|
12
23
|
Initial release.
|
13
24
|
|
14
25
|
[Keep a Changelog]: http://keepachangelog.com/en/1.0.0/
|
15
26
|
[Semantic Versioning]: http://semver.org/spec/v2.0.0.html
|
16
|
-
[
|
27
|
+
[0.2.0]: https://github.com/agorf/greeklish_iso843/compare/0.1.0...0.2.0
|
28
|
+
[Unreleased]: https://github.com/agorf/greeklish_iso843/compare/0.2.0...HEAD
|
data/README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# greeklish_iso843
|
2
2
|
|
3
3
|
A [Ruby][] library that converts Greek text to [Greeklish][], conforming to the
|
4
|
-
[ISO 843][] (ELOT 743) standard
|
4
|
+
[ISO 843][] (ELOT 743) standard used by the Greek State.
|
5
5
|
|
6
6
|
[Ruby]: https://www.ruby-lang.org/en/
|
7
7
|
[Greeklish]: https://en.wikipedia.org/wiki/Greeklish
|
8
8
|
[ISO 843]: https://www.iso.org/standard/5215.html
|
9
|
-
[state]: http://www.passport.gov.gr/passports/GrElotConverter/GrElotConverter.html
|
10
9
|
|
11
10
|
## Installation
|
12
11
|
|
@@ -31,7 +30,8 @@ Then you can use it to convert text:
|
|
31
30
|
```ruby
|
32
31
|
GreeklishIso843::Converter.convert("Μπάμπης") # => "Bampis"
|
33
32
|
GreeklishIso843::Converter.convert("Άγγελος") # => "Angelos"
|
34
|
-
GreeklishIso843::Converter.convert("Ευάγγελος") # => "
|
33
|
+
GreeklishIso843::Converter.convert("Ευάγγελος") # => "Evangelos"
|
34
|
+
GreeklishIso843::Converter.convert("άνευ αποδοχών") # => "anef apodochon"
|
35
35
|
```
|
36
36
|
|
37
37
|
Alternatively, you can require the `String` core extension for more convenience:
|
@@ -44,8 +44,6 @@ Then you can use it to convert text:
|
|
44
44
|
|
45
45
|
```ruby
|
46
46
|
"Μπάμπης".to_greeklish # => "Bampis"
|
47
|
-
"Άγγελος".to_greeklish # => "Angelos"
|
48
|
-
"Ευάγγελος".to_greeklish # => "Efangelos"
|
49
47
|
```
|
50
48
|
|
51
49
|
There's also a command line utility that accepts Greek text from the standard
|
@@ -54,20 +52,18 @@ input and prints the corresponding Greeklish text to the standard output:
|
|
54
52
|
```sh
|
55
53
|
$ greeklish_iso843
|
56
54
|
Μπάμπης
|
57
|
-
Άγγελος
|
58
|
-
Ευάγγελος
|
59
55
|
^D
|
60
56
|
Bampis
|
61
|
-
Angelos
|
62
|
-
Efangelos
|
63
57
|
$
|
64
58
|
```
|
65
59
|
|
66
60
|
Note: `^D` represents the EOF (End Of File) character, emitted with `Ctrl-D`.
|
67
61
|
|
68
|
-
##
|
62
|
+
## Acknowledgements
|
69
63
|
|
70
|
-
|
64
|
+
This library was based on [an official implementation in JavaScript][js].
|
65
|
+
|
66
|
+
[js]: http://www.passport.gov.gr/passports/GrElotConverter/GrElotConverter.html
|
71
67
|
|
72
68
|
## License
|
73
69
|
|
@@ -64,6 +64,8 @@ class GreeklishIso843::Converter
|
|
64
64
|
'ώ' => 'o'
|
65
65
|
}.freeze
|
66
66
|
|
67
|
+
REPLACEMENTS_REGEXP = /#{REPLACEMENTS.keys.join('|')}/i.freeze
|
68
|
+
|
67
69
|
BLANK_REGEXP = /\A[[:space:]]*\z/.freeze
|
68
70
|
|
69
71
|
attr_reader :text
|
@@ -77,19 +79,18 @@ class GreeklishIso843::Converter
|
|
77
79
|
end
|
78
80
|
|
79
81
|
def convert
|
80
|
-
text.gsub(
|
82
|
+
text.gsub(REPLACEMENTS_REGEXP) do |match|
|
81
83
|
match_data = Regexp.last_match
|
82
|
-
|
84
|
+
greeklish = REPLACEMENTS[match.downcase]
|
85
|
+
prev_char = match_data.pre_match[-1]&.downcase
|
86
|
+
next_char = match_data.post_match[0]&.downcase
|
83
87
|
|
84
|
-
if
|
85
|
-
|
86
|
-
greek = match + match_data.post_match[0].to_s
|
88
|
+
if greeklish
|
89
|
+
greek = match + next_char.to_s
|
87
90
|
elsif match.casecmp?('μπ')
|
88
91
|
greeklish =
|
89
|
-
if
|
90
|
-
GREEK_LOWER[
|
91
|
-
present?(match_data.post_match) &&
|
92
|
-
GREEK_LOWER[match_data.post_match[0].downcase]
|
92
|
+
if prev_char && GREEK_LOWER[prev_char] &&
|
93
|
+
next_char && GREEK_LOWER[next_char]
|
93
94
|
'mp'
|
94
95
|
else
|
95
96
|
'b'
|
@@ -99,9 +100,13 @@ class GreeklishIso843::Converter
|
|
99
100
|
greeklish = 'ts'
|
100
101
|
greek = match
|
101
102
|
else
|
102
|
-
|
103
|
-
|
104
|
-
|
103
|
+
greeklish =
|
104
|
+
REPLACEMENTS[match[0].downcase] +
|
105
|
+
if next_char && 'αάεέηήιίϊΐοόυύϋΰωώβγδζλμνρ'[next_char]
|
106
|
+
'v'
|
107
|
+
else
|
108
|
+
'f'
|
109
|
+
end
|
105
110
|
greek = match
|
106
111
|
end
|
107
112
|
|
@@ -114,14 +119,14 @@ class GreeklishIso843::Converter
|
|
114
119
|
end
|
115
120
|
|
116
121
|
private def fix_case(greeklish, greek)
|
117
|
-
if capitalized?(greek[0])
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
122
|
+
if !capitalized?(greek[0])
|
123
|
+
return greeklish
|
124
|
+
end
|
125
|
+
|
126
|
+
if greek.length == 1 || capitalized?(greek[1])
|
127
|
+
greeklish.upcase
|
123
128
|
else
|
124
|
-
greeklish
|
129
|
+
greeklish[0].upcase + greeklish[1..-1]
|
125
130
|
end
|
126
131
|
end
|
127
132
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: greeklish_iso843
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Angelos Orfanakos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: rubygems@angelos.dev
|