medieval_latina 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/medieval_latina.rb +34 -21
- data/lib/medieval_latina/dictionary.rb +5 -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: 6b2dbf4d62fea9a0a7a3d06f6a66c3902eb85ba0605eb927c6f390c2ac7367e3
|
4
|
+
data.tar.gz: 5396df26ae69ce6c0c4b3cd59d6af0b242246b31e4fac33698dc9ad1cafbb912
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3817575ebbb2313e5c0ff600f44aa6cd94b0968212490b0853293b5cd7ef787e3999c59317c10347e1f6409cd48d6e74d0e4ca79c9bf738fe9c8e9f7b2d84957
|
7
|
+
data.tar.gz: 400e0dc6c1b3adff85c6e1dbcaa81f642cec74f8c1e046c107568a65e552082700156175d6690f057110981013a84584b660014e7bf62b5be03e222d75e79312
|
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
|
|
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 do |word|
|
7
|
+
DICTIONARY[word.downcase] || new(word).call
|
8
|
+
end.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,7 +29,7 @@ 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" },
|
@@ -42,24 +44,22 @@ class MedievalLatina
|
|
42
44
|
|
43
45
|
Result = Struct.new(:substring, :increment_by)
|
44
46
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
CONSONENTS[character.intern].call(rest)
|
49
|
-
else
|
50
|
-
character
|
47
|
+
def consonant(substring)
|
48
|
+
consonant_team = CONSONENT_TEAMS[substring.to_team]
|
49
|
+
consonant = if CONSONENTS.key?(substring.character.intern)
|
50
|
+
CONSONENTS[substring.character.intern].call(substring.rest)
|
51
51
|
end
|
52
52
|
|
53
|
-
if
|
54
|
-
Result.new(
|
55
|
-
elsif
|
56
|
-
Result.new(
|
53
|
+
if consonant_team
|
54
|
+
Result.new(consonant_team, 2)
|
55
|
+
elsif consonant
|
56
|
+
Result.new(consonant, 1)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def vowel(
|
61
|
-
vowel_team = VOWEL_TEAMS[
|
62
|
-
vowel = VOWELS[character.intern]
|
60
|
+
def vowel(substring)
|
61
|
+
vowel_team = VOWEL_TEAMS[substring.to_team]
|
62
|
+
vowel = VOWELS[substring.character.intern]
|
63
63
|
|
64
64
|
if vowel_team
|
65
65
|
Result.new(vowel_team, 2)
|
@@ -68,5 +68,18 @@ class MedievalLatina
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
class Substring
|
72
|
+
attr_reader :character, :rest
|
73
|
+
|
74
|
+
def initialize(text, index)
|
75
|
+
@character = text[index]
|
76
|
+
@rest = text.chars.drop(index + 1).join
|
77
|
+
end
|
78
|
+
|
79
|
+
def to_team
|
80
|
+
"#{character}#{rest.chars.first}".intern
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
71
84
|
class Error < StandardError; end
|
72
85
|
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.2
|
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-09 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
|