medieval_latina 1.0.0 → 1.0.5
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 +2 -2
- data/lib/medieval_latina.rb +39 -19
- data/lib/medieval_latina/dictionary.rb +6 -0
- data/lib/medieval_latina/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c06b0c32b7d109557cf9b154a7812e30364cba0e3a5b11f60414f8eab4958d94
|
4
|
+
data.tar.gz: 80acf05a755efa9356a116144b9d58ba99ab38a10360db8aea33b20f16c639c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edd6ec30087938df343b18308455b92ad8fdc72038aed09e62e577a1d14b37d10407dfa6e8e0af70fd336eff6374a6624ea9cb3a8c429f81170c9c0cfccaf628
|
7
|
+
data.tar.gz: '083e33f1622314f31279462c22eba47b62fec9a357562e16cc9ff7d3eeefcbf2ac8cf46fb517438f3dfe2cbd9a32d0e7873426ee091ac1bd4c60a2c1b8efcf8d'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# MedievalLatina
|
2
2
|
|
3
3
|
There are good text-to-speech engines for English and classical Latin, but none for medieval Latin.
|
4
|
-
`MedievalLatina` converts Latin text to a kind of phonetic spelling that can be read by English text-to-speech engines.
|
4
|
+
`MedievalLatina` converts Latin text to a kind of phonetic spelling that can be read by English language text-to-speech engines.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -35,7 +35,7 @@ Then, run `rake spec` to run the tests.
|
|
35
35
|
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
36
36
|
|
37
37
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
38
|
-
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
38
|
+
To release a new version, update the version number in `version.rb`, run `bin/setup` to increment the version in the lock file, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
39
39
|
Run `standardrb --fix` before submitting any changes, to help keep the code formatting uniform.
|
40
40
|
|
41
41
|
## Contributing
|
data/lib/medieval_latina.rb
CHANGED
@@ -1,22 +1,24 @@
|
|
1
|
+
require "medieval_latina/dictionary"
|
1
2
|
require "medieval_latina/version"
|
2
3
|
|
3
4
|
class MedievalLatina
|
4
5
|
def self.[](text)
|
5
|
-
|
6
|
+
text.split(" ").map { |word|
|
7
|
+
DICTIONARY[word.downcase] || new(word).call
|
8
|
+
}.join(" ")
|
6
9
|
end
|
7
10
|
|
8
|
-
def initialize(
|
11
|
+
def initialize(word)
|
9
12
|
@index = 0
|
10
|
-
@
|
13
|
+
@word = word
|
11
14
|
end
|
12
15
|
|
13
16
|
def call
|
14
17
|
array = []
|
15
18
|
|
16
|
-
until index >=
|
17
|
-
|
18
|
-
|
19
|
-
result = vowel(character, rest.chars.first) || consonent(character, rest)
|
19
|
+
until index >= word.length
|
20
|
+
substring = Substring.new(word, index)
|
21
|
+
result = vowel(substring) || consonant(substring) || Result.new(substring.character, 1)
|
20
22
|
array.push(result.substring)
|
21
23
|
self.index = index + result.increment_by
|
22
24
|
end
|
@@ -27,33 +29,38 @@ class MedievalLatina
|
|
27
29
|
private
|
28
30
|
|
29
31
|
attr_accessor :index
|
30
|
-
attr_reader :
|
32
|
+
attr_reader :word
|
31
33
|
|
32
34
|
CONSONENTS = {
|
33
35
|
c: ->(rest) { SOFT_C.any? { |item| rest.start_with?(item) } ? "ch" : "k" },
|
34
36
|
g: ->(rest) { SOFT_G.any? { |item| rest.start_with?(item) } ? "j" : "g" },
|
35
|
-
j: ->(rest) { "y" }
|
37
|
+
j: ->(rest) { "y" },
|
38
|
+
x: ->(rest) { "ks" }
|
36
39
|
}
|
40
|
+
CONSONENT_TEAMS = {qu: "kw"}
|
37
41
|
SOFT_C = ["e", "i", "ae", "oe"]
|
38
42
|
SOFT_G = SOFT_C
|
39
|
-
VOWEL_TEAMS = {ae: "ay", oe: "ay", au: "
|
43
|
+
VOWEL_TEAMS = {ae: "ay", oe: "ay", au: "ou"}
|
40
44
|
VOWELS = {a: "ah", e: "ay", i: "ee", o: "oh", u: "oo"}
|
41
45
|
|
42
46
|
Result = Struct.new(:substring, :increment_by)
|
43
47
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
character
|
48
|
+
def consonant(substring)
|
49
|
+
consonant_team = CONSONENT_TEAMS[substring.to_team]
|
50
|
+
consonant = if CONSONENTS.key?(substring.character.intern)
|
51
|
+
CONSONENTS[substring.character.intern].call(substring.rest)
|
49
52
|
end
|
50
53
|
|
51
|
-
|
54
|
+
if consonant_team
|
55
|
+
Result.new(consonant_team, 2)
|
56
|
+
elsif consonant
|
57
|
+
Result.new(consonant, 1)
|
58
|
+
end
|
52
59
|
end
|
53
60
|
|
54
|
-
def vowel(
|
55
|
-
vowel_team = VOWEL_TEAMS[
|
56
|
-
vowel = VOWELS[character.intern]
|
61
|
+
def vowel(substring)
|
62
|
+
vowel_team = VOWEL_TEAMS[substring.to_team]
|
63
|
+
vowel = VOWELS[substring.character.intern]
|
57
64
|
|
58
65
|
if vowel_team
|
59
66
|
Result.new(vowel_team, 2)
|
@@ -62,5 +69,18 @@ class MedievalLatina
|
|
62
69
|
end
|
63
70
|
end
|
64
71
|
|
72
|
+
class Substring
|
73
|
+
attr_reader :character, :rest
|
74
|
+
|
75
|
+
def initialize(text, index)
|
76
|
+
@character = text[index]
|
77
|
+
@rest = text.chars.drop(index + 1).join
|
78
|
+
end
|
79
|
+
|
80
|
+
def to_team
|
81
|
+
"#{character}#{rest.chars.first}".intern
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
65
85
|
class Error < StandardError; end
|
66
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: medieval_latina
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jayson Virissimo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
There are good text-to-speech engines for English and classical Latin, but none for medieval Latin.
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- bin/console
|
31
31
|
- bin/setup
|
32
32
|
- lib/medieval_latina.rb
|
33
|
+
- lib/medieval_latina/dictionary.rb
|
33
34
|
- lib/medieval_latina/version.rb
|
34
35
|
- medieval_latina.gemspec
|
35
36
|
homepage: https://github.com/jaysonvirissimo/medieval_latina
|