medieval_latina 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +3 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -1
- data/lib/medieval_latina/dictionary.rb +2029 -48
- data/lib/medieval_latina/initializer.rb +3 -0
- data/lib/medieval_latina/version.rb +1 -1
- data/lib/medieval_latina.rb +20 -4
- data/medieval_latina.gemspec +2 -1
- metadata +19 -4
data/lib/medieval_latina.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "medieval_latina/dictionary"
|
2
|
+
require "medieval_latina/initializer"
|
2
3
|
require "medieval_latina/version"
|
3
4
|
require "set"
|
4
5
|
|
@@ -6,7 +7,13 @@ class MedievalLatina
|
|
6
7
|
def self.[](text)
|
7
8
|
prepared_words = prepare_text(text).map do |string|
|
8
9
|
if word?(string)
|
9
|
-
|
10
|
+
metadata = DICTIONARY.fetch(string, {})
|
11
|
+
|
12
|
+
if metadata.key?(:pronunciation)
|
13
|
+
metadata[:pronunciation]
|
14
|
+
else
|
15
|
+
new(string).call
|
16
|
+
end
|
10
17
|
else
|
11
18
|
string
|
12
19
|
end
|
@@ -16,7 +23,7 @@ class MedievalLatina
|
|
16
23
|
end
|
17
24
|
|
18
25
|
def self.prepare_text(text)
|
19
|
-
text.scan(/[\
|
26
|
+
text.scan(/[\p{Alnum}'-]+|[[:punct:]]+/).map do |string|
|
20
27
|
if word?(string)
|
21
28
|
prepare_word(string)
|
22
29
|
else
|
@@ -26,7 +33,7 @@ class MedievalLatina
|
|
26
33
|
end
|
27
34
|
|
28
35
|
def self.prepare_word(word)
|
29
|
-
word.gsub(/\
|
36
|
+
word.gsub(/\P{Alnum}+/, " ").strip.downcase
|
30
37
|
end
|
31
38
|
|
32
39
|
def self.adjective?(word)
|
@@ -80,7 +87,7 @@ class MedievalLatina
|
|
80
87
|
|
81
88
|
def initialize(word)
|
82
89
|
@index = 0
|
83
|
-
@word = word.downcase
|
90
|
+
@word = I18n.transliterate(word.downcase)
|
84
91
|
end
|
85
92
|
|
86
93
|
def call
|
@@ -155,4 +162,13 @@ class MedievalLatina
|
|
155
162
|
end
|
156
163
|
|
157
164
|
class Error < StandardError; end
|
165
|
+
|
166
|
+
DICTIONARY = FREQUENCY_LIST.each_with_object({}) do |(word, metadata), hash|
|
167
|
+
hash[word] = metadata
|
168
|
+
|
169
|
+
sanitized_word = I18n.transliterate(word)
|
170
|
+
unless hash.key?(sanitized_word)
|
171
|
+
hash[sanitized_word] = metadata
|
172
|
+
end
|
173
|
+
end
|
158
174
|
end
|
data/medieval_latina.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.description = description
|
16
16
|
spec.homepage = "https://github.com/jaysonvirissimo/medieval_latina"
|
17
17
|
spec.license = "MIT"
|
18
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
18
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
19
19
|
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
20
20
|
spec.metadata["homepage_uri"] = spec.homepage
|
21
21
|
spec.metadata["source_code_uri"] = github_uri
|
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.bindir = "exe"
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ["lib"]
|
31
|
+
spec.add_dependency "i18n"
|
31
32
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: medieval_latina
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jayson Virissimo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
12
|
-
dependencies:
|
11
|
+
date: 2023-08-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: i18n
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: |
|
14
28
|
There are good text-to-speech engines for English and classical Latin, but none for medieval Latin.
|
15
29
|
MedievalLatina converts Latin text to a kind of phonetic spelling that can be read by English text-to-speech engines.
|
@@ -33,6 +47,7 @@ files:
|
|
33
47
|
- bin/setup
|
34
48
|
- lib/medieval_latina.rb
|
35
49
|
- lib/medieval_latina/dictionary.rb
|
50
|
+
- lib/medieval_latina/initializer.rb
|
36
51
|
- lib/medieval_latina/version.rb
|
37
52
|
- medieval_latina.gemspec
|
38
53
|
homepage: https://github.com/jaysonvirissimo/medieval_latina
|
@@ -51,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
66
|
requirements:
|
52
67
|
- - ">="
|
53
68
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
69
|
+
version: 2.7.0
|
55
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
71
|
requirements:
|
57
72
|
- - ">="
|