medieval_latina 3.1.2 → 3.2.0

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.
data/lexicons/Latin08.pls CHANGED
@@ -1,132 +1,4 @@
1
1
  <lexicon version='1.0' xmlns='http://www.w3.org/2005/01/pronunciation-lexicon' alphabet='ipa' xml:lang='en-US'>
2
- <lexeme>
3
- <grapheme>
4
- conscius
5
- </grapheme>
6
- <phoneme>
7
- ˈkɔnskɪʊs
8
- </phoneme>
9
- </lexeme>
10
- <lexeme>
11
- <grapheme>
12
- crudelis
13
- </grapheme>
14
- <phoneme>
15
- ˈkrudɛlɪs
16
- </phoneme>
17
- </lexeme>
18
- <lexeme>
19
- <grapheme>
20
- cupidus
21
- </grapheme>
22
- <phoneme>
23
- ˈkupɪdʊs
24
- </phoneme>
25
- </lexeme>
26
- <lexeme>
27
- <grapheme>
28
- demens
29
- </grapheme>
30
- <phoneme>
31
- ˈdɛmɛns
32
- </phoneme>
33
- </lexeme>
34
- <lexeme>
35
- <grapheme>
36
- desidiosus
37
- </grapheme>
38
- <phoneme>
39
- dɛsɪˈdjɔsʊs
40
- </phoneme>
41
- </lexeme>
42
- <lexeme>
43
- <grapheme>
44
- dignus
45
- </grapheme>
46
- <phoneme>
47
- ˈdɪɲnʊs
48
- </phoneme>
49
- </lexeme>
50
- <lexeme>
51
- <grapheme>
52
- doctus
53
- </grapheme>
54
- <phoneme>
55
- ˈdɔktʊs
56
- </phoneme>
57
- </lexeme>
58
- <lexeme>
59
- <grapheme>
60
- eloquens
61
- </grapheme>
62
- <phoneme>
63
- ɛˈlɔkwɛns
64
- </phoneme>
65
- </lexeme>
66
- <lexeme>
67
- <grapheme>
68
- eximius
69
- </grapheme>
70
- <phoneme>
71
- ɛkˈsɪmɪʊs
72
- </phoneme>
73
- </lexeme>
74
- <lexeme>
75
- <grapheme>
76
- fortunatus
77
- </grapheme>
78
- <phoneme>
79
- fɔrtʊˈnatʊs
80
- </phoneme>
81
- </lexeme>
82
- <lexeme>
83
- <grapheme>
84
- humilis
85
- </grapheme>
86
- <phoneme>
87
- ˈhʊmɪlɪs
88
- </phoneme>
89
- </lexeme>
90
- <lexeme>
91
- <grapheme>
92
- immortalis
93
- </grapheme>
94
- <phoneme>
95
- ɪmˈmɔrtalɪs
96
- </phoneme>
97
- </lexeme>
98
- <lexeme>
99
- <grapheme>
100
- inanis
101
- </grapheme>
102
- <phoneme>
103
- ɪˈnanɪs
104
- </phoneme>
105
- </lexeme>
106
- <lexeme>
107
- <grapheme>
108
- incertus
109
- </grapheme>
110
- <phoneme>
111
- ɪnˈkɛrtʊs
112
- </phoneme>
113
- </lexeme>
114
- <lexeme>
115
- <grapheme>
116
- infirmus
117
- </grapheme>
118
- <phoneme>
119
- ɪnˈfɪrmʊs
120
- </phoneme>
121
- </lexeme>
122
- <lexeme>
123
- <grapheme>
124
- informis
125
- </grapheme>
126
- <phoneme>
127
- ɪnˈfɔrmɪs
128
- </phoneme>
129
- </lexeme>
130
2
  <lexeme>
131
3
  <grapheme>
132
4
  iniustus
@@ -2175,36 +2047,4 @@
2175
2047
  uˈsur.po
2176
2048
  </phoneme>
2177
2049
  </lexeme>
2178
- <lexeme>
2179
- <grapheme>
2180
- vagor
2181
- </grapheme>
2182
- <phoneme>
2183
- ˈva.gor
2184
- </phoneme>
2185
- </lexeme>
2186
- <lexeme>
2187
- <grapheme>
2188
- versor
2189
- </grapheme>
2190
- <phoneme>
2191
- ˈver.sor
2192
- </phoneme>
2193
- </lexeme>
2194
- <lexeme>
2195
- <grapheme>
2196
- verto
2197
- </grapheme>
2198
- <phoneme>
2199
- ˈver.to
2200
- </phoneme>
2201
- </lexeme>
2202
- <lexeme>
2203
- <grapheme>
2204
- vigilo
2205
- </grapheme>
2206
- <phoneme>
2207
- viˈdʒi.lo
2208
- </phoneme>
2209
- </lexeme>
2210
2050
  </lexicon>
data/lexicons/Latin09.pls CHANGED
@@ -1,4 +1,36 @@
1
1
  <lexicon version='1.0' xmlns='http://www.w3.org/2005/01/pronunciation-lexicon' alphabet='ipa' xml:lang='en-US'>
2
+ <lexeme>
3
+ <grapheme>
4
+ vagor
5
+ </grapheme>
6
+ <phoneme>
7
+ ˈva.gor
8
+ </phoneme>
9
+ </lexeme>
10
+ <lexeme>
11
+ <grapheme>
12
+ versor
13
+ </grapheme>
14
+ <phoneme>
15
+ ˈver.sor
16
+ </phoneme>
17
+ </lexeme>
18
+ <lexeme>
19
+ <grapheme>
20
+ verto
21
+ </grapheme>
22
+ <phoneme>
23
+ ˈver.to
24
+ </phoneme>
25
+ </lexeme>
26
+ <lexeme>
27
+ <grapheme>
28
+ vigilo
29
+ </grapheme>
30
+ <phoneme>
31
+ viˈdʒi.lo
32
+ </phoneme>
33
+ </lexeme>
2
34
  <lexeme>
3
35
  <grapheme>
4
36
  vulnero
@@ -7,4 +39,12 @@
7
39
  ˈvul.ne.ro
8
40
  </phoneme>
9
41
  </lexeme>
42
+ <lexeme>
43
+ <grapheme>
44
+ caelis
45
+ </grapheme>
46
+ <phoneme>
47
+ tʃɛlis
48
+ </phoneme>
49
+ </lexeme>
10
50
  </lexicon>
@@ -5,13 +5,14 @@ class MedievalLatina
5
5
  class LexiconBuilder
6
6
  include REXML
7
7
 
8
- def initialize(words)
8
+ def initialize(words, lang: "en-US")
9
9
  @document = Document.new
10
10
  @words = words
11
+ @lang = lang
11
12
  end
12
13
 
13
14
  def call
14
- document.add_element "lexicon", SPECIFICATION
15
+ document.add_element "lexicon", SPECIFICATION.merge("xml:lang" => lang)
15
16
 
16
17
  words.each do |word, pronunciation|
17
18
  lexeme = Element.new("lexeme")
@@ -32,13 +33,12 @@ class MedievalLatina
32
33
 
33
34
  private
34
35
 
35
- attr_reader :document, :words
36
+ attr_reader :document, :words, :lang
36
37
 
37
38
  SPECIFICATION = {
38
39
  "version" => "1.0",
39
40
  "xmlns" => "http://www.w3.org/2005/01/pronunciation-lexicon",
40
- "alphabet" => "ipa",
41
- "xml:lang" => "en-US"
41
+ "alphabet" => "ipa"
42
42
  }.freeze
43
43
  end
44
44
  end
@@ -1,3 +1,3 @@
1
1
  class MedievalLatina
2
- VERSION = "3.1.2".freeze
2
+ VERSION = "3.2.0".freeze
3
3
  end
@@ -8,7 +8,7 @@ class MedievalLatina
8
8
  def self.[](text)
9
9
  prepared_words = prepare_text(text).map do |string|
10
10
  if word?(string)
11
- metadata = DICTIONARY.fetch(string, {})
11
+ metadata = entry_for(string) || {}
12
12
 
13
13
  if metadata.key?("pronunciation")
14
14
  metadata["pronunciation"]
@@ -46,20 +46,31 @@ class MedievalLatina
46
46
  word.gsub(/\P{Alnum}+/, " ").strip.downcase
47
47
  end
48
48
 
49
+ # Exact spelling first, then a macron-stripped fallback.
50
+ def self.entry_for(word)
51
+ key = word.to_s.downcase
52
+ DICTIONARY[key] || NORMALIZED[I18n.transliterate(key)]
53
+ end
54
+
49
55
  def self.adjective?(word)
50
- adjectives.key?(prepare_word(word))
56
+ part?(word, "Adjective")
51
57
  end
52
58
 
53
59
  def self.adverb?(word)
54
- adverbs.key?(prepare_word(word))
60
+ part?(word, "Adverb")
55
61
  end
56
62
 
57
63
  def self.noun?(word)
58
- nouns.key?(prepare_word(word))
64
+ part?(word, "Noun")
59
65
  end
60
66
 
61
67
  def self.verb?(word)
62
- verbs.key?(prepare_word(word))
68
+ part?(word, "Verb")
69
+ end
70
+
71
+ def self.part?(word, part)
72
+ entry = entry_for(prepare_word(word))
73
+ !entry.nil? && entry["part"] == part
63
74
  end
64
75
 
65
76
  def self.adjectives
@@ -82,7 +93,7 @@ class MedievalLatina
82
93
 
83
94
  def self.pronunciations_for(words)
84
95
  words.map(&:downcase).each_with_object({}) do |word, hash|
85
- metadata = DICTIONARY[word]
96
+ metadata = entry_for(word)
86
97
 
87
98
  if metadata && metadata["ipa"]
88
99
  hash[word] = metadata["ipa"]
@@ -200,12 +211,13 @@ class MedievalLatina
200
211
 
201
212
  class Error < StandardError; end
202
213
 
203
- DICTIONARY = dictionary.each_with_object({}) do |(word, metadata), hash|
204
- hash[word] = metadata
214
+ DICTIONARY = dictionary
205
215
 
206
- sanitized_word = I18n.transliterate(word)
207
- unless hash.key?(sanitized_word)
208
- hash[sanitized_word] = metadata
209
- end
216
+ # Macron-stripped fallback; exact keys win, earliest entry wins on collision.
217
+ NORMALIZED = DICTIONARY.each_with_object({}) do |(word, metadata), hash|
218
+ normalized = I18n.transliterate(word)
219
+ next if DICTIONARY.key?(normalized)
220
+
221
+ hash[normalized] ||= metadata
210
222
  end
211
223
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  # Specify which files should be added to the gem when it is released.
24
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
25
  spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|audio)/}) }
27
27
  end
28
28
  spec.bindir = "exe"
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: medieval_latina
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jayson Virissimo
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-09-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: i18n
@@ -109,6 +109,7 @@ files:
109
109
  - ".rspec"
110
110
  - ".standard.yml"
111
111
  - ".tool-versions"
112
+ - AGENTS.md
112
113
  - CLAUDE.md
113
114
  - Gemfile
114
115
  - Gemfile.lock
@@ -118,6 +119,7 @@ files:
118
119
  - bin/build
119
120
  - bin/console
120
121
  - bin/lint
122
+ - bin/sample_audio
121
123
  - bin/setup
122
124
  - data/dictionary.json
123
125
  - lexicons/Latin00.pls
@@ -158,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
160
  - !ruby/object:Gem::Version
159
161
  version: '0'
160
162
  requirements: []
161
- rubygems_version: 3.6.2
163
+ rubygems_version: 4.0.10
162
164
  specification_version: 4
163
165
  summary: Transform medieval Latin text into phonetic English
164
166
  test_files: []