Class: MedievalLatina::LexiconBuilder
- Inherits:
-
Object
- Object
- MedievalLatina::LexiconBuilder
- Defined in:
- lib/medieval_latina/lexicon_builder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize ⇒ LexiconBuilder
constructor
A new instance of LexiconBuilder.
- #write ⇒ Object
Constructor Details
#initialize ⇒ LexiconBuilder
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
.write ⇒ Object
5 6 7 |
# File 'lib/medieval_latina/lexicon_builder.rb', line 5 def self.write new.call.write end |
Instance Method Details
#call ⇒ Object
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 |
#write ⇒ Object
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 |