medieval_latina 2.0.5 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,61 @@
1
+ require "builder"
2
+
3
+ class MedievalLatina
4
+ class LexiconBuilder
5
+ def self.write
6
+ new.call.write
7
+ end
8
+
9
+ def initialize
10
+ @hash = parts.each_with_object({}) do |part, hash|
11
+ hash.merge(part)
12
+ end
13
+
14
+ FREQUENCY_LIST.each do |word, metadata|
15
+ if metadata.key?(:ipa)
16
+ @hash[word] = metadata[:ipa]
17
+ end
18
+ end
19
+
20
+ @xml = Builder::XmlMarkup.new(indent: 2)
21
+ end
22
+
23
+ def call
24
+ xml.instruct! :xml, encoding: "UTF-8"
25
+ xml.lexicon(xmlns: URL, version: "1.0") do
26
+ grouped_hash.each do |phonetics, words|
27
+ xml.lexeme do
28
+ words.each { |word| xml.grapheme word }
29
+ xml.phoneme phonetics
30
+ end
31
+ end
32
+ end
33
+
34
+ self
35
+ end
36
+
37
+ def write
38
+ File.open("lexicon.pls", "w") do |file|
39
+ file.write(xml.target!)
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ attr_reader :hash, :xml
46
+
47
+ def grouped_hash
48
+ hash.group_by do |_, phonetics|
49
+ phonetics
50
+ end.transform_values do |pairs|
51
+ pairs.map(&:first)
52
+ end
53
+ end
54
+
55
+ def parts
56
+ [ADJECTIVES, ADVERBS, NOUNS, VERBS]
57
+ end
58
+
59
+ URL = "http://www.w3.org/2005/01/pronunciation-lexicon".freeze
60
+ end
61
+ end
@@ -1,3 +1,3 @@
1
1
  class MedievalLatina
2
- VERSION = "2.0.5".freeze
2
+ VERSION = "2.1.1".freeze
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require "medieval_latina/dictionary"
2
2
  require "medieval_latina/initializer"
3
+ require "medieval_latina/lexicon_builder"
3
4
  require "medieval_latina/version"
4
5
  require "set"
5
6
 
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: 2.0.5
4
+ version: 2.1.1
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-11-28 00:00:00.000000000 Z
11
+ date: 2023-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -43,11 +43,14 @@ files:
43
43
  - LICENSE.txt
44
44
  - README.md
45
45
  - Rakefile
46
+ - bin/build
46
47
  - bin/console
47
48
  - bin/setup
49
+ - lexicon.pls
48
50
  - lib/medieval_latina.rb
49
51
  - lib/medieval_latina/dictionary.rb
50
52
  - lib/medieval_latina/initializer.rb
53
+ - lib/medieval_latina/lexicon_builder.rb
51
54
  - lib/medieval_latina/version.rb
52
55
  - medieval_latina.gemspec
53
56
  homepage: https://github.com/jaysonvirissimo/medieval_latina