medieval_latina 2.0.1 → 2.1.1

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.
@@ -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.1".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
 
@@ -37,31 +38,31 @@ class MedievalLatina
37
38
  end
38
39
 
39
40
  def self.adjective?(word)
40
- ADJECTIVES.member?(prepare_word(word))
41
+ ADJECTIVES.key?(prepare_word(word))
41
42
  end
42
43
 
43
44
  def self.adverb?(word)
44
- ADVERBS.member?(prepare_word(word))
45
+ ADVERBS.key?(prepare_word(word))
45
46
  end
46
47
 
47
48
  def self.noun?(word)
48
- NOUNS.member?(prepare_word(word))
49
+ NOUNS.key?(prepare_word(word))
49
50
  end
50
51
 
51
52
  def self.verb?(word)
52
- VERBS.member?(prepare_word(word))
53
+ VERBS.key?(prepare_word(word))
53
54
  end
54
55
 
55
56
  def self.adjectives
56
- ADJECTIVES
57
+ ADJECTIVES.keys
57
58
  end
58
59
 
59
60
  def self.adverbs
60
- ADVERBS
61
+ ADVERBS.keys
61
62
  end
62
63
 
63
64
  def self.nouns
64
- NOUNS
65
+ NOUNS.keys
65
66
  end
66
67
 
67
68
  def self.rejoin_words(array)
@@ -74,7 +75,7 @@ class MedievalLatina
74
75
  end
75
76
 
76
77
  def self.verbs
77
- VERBS
78
+ VERBS.keys
78
79
  end
79
80
 
80
81
  def self.word?(string)
@@ -82,7 +83,13 @@ class MedievalLatina
82
83
  end
83
84
 
84
85
  def self.words
85
- ADJECTIVES | ADVERBS | Set.new(DICTIONARY.keys) | NOUNS | VERBS
86
+ [
87
+ ADJECTIVES,
88
+ ADVERBS,
89
+ DICTIONARY,
90
+ NOUNS,
91
+ VERBS
92
+ ].flat_map(&:keys).each_with_object(Set.new) { |word, set| set.add(word) }
86
93
  end
87
94
 
88
95
  def initialize(word)
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.1
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-08-21 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