Class: MedievalLatina::LexiconBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/medieval_latina/lexicon_builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLexiconBuilder

Returns a new instance of LexiconBuilder.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/medieval_latina/lexicon_builder.rb', line 9

def initialize
  @hash = parts.each_with_object({}) do |part, hash|
    hash.merge(part)
  end

  FREQUENCY_LIST.each do |word, |
    if .key?(:ipa)
      @hash[word] = [:ipa]
    end
  end

  @xml = Builder::XmlMarkup.new(indent: 2)
end

Class Method Details

.writeObject



5
6
7
# File 'lib/medieval_latina/lexicon_builder.rb', line 5

def self.write
  new.call.write
end

Instance Method Details

#callObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/medieval_latina/lexicon_builder.rb', line 23

def call
  xml.instruct! :xml, encoding: "UTF-8"
  xml.lexicon(xmlns: URL, version: "1.0") do
    grouped_hash.each do |phonetics, words|
      xml.lexeme do
        words.each { |word| xml.grapheme word }
        xml.phoneme phonetics
      end
    end
  end

  self
end

#writeObject



37
38
39
40
41
# File 'lib/medieval_latina/lexicon_builder.rb', line 37

def write
  File.open("lexicon.pls", "w") do |file|
    file.write(xml.target!)
  end
end