-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6807a32
commit 4a930eb
Showing
5 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require "builder" | ||
|
||
class MedievalLatina | ||
class LexiconBuilder | ||
def initialize | ||
@hash = parts.each_with_object({}) do |part, hash| | ||
hash.merge(part) | ||
end | ||
|
||
FREQUENCY_LIST.each do |word, metadata| | ||
if metadata.key?(:ipa) | ||
@hash[word] = metadata[:ipa] | ||
end | ||
end | ||
|
||
@xml = Builder::XmlMarkup.new(indent: 2) | ||
end | ||
|
||
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 | ||
end | ||
|
||
private | ||
|
||
attr_reader :hash, :xml | ||
|
||
def grouped_hash | ||
hash.group_by do |_, phonetics| | ||
phonetics | ||
end.transform_values do |pairs| | ||
pairs.map(&:first) | ||
end | ||
end | ||
|
||
def parts | ||
[ADJECTIVES, ADVERBS, NOUNS, VERBS] | ||
end | ||
|
||
URL = "http://www.w3.org/2005/01/pronunciation-lexicon".freeze | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
class MedievalLatina | ||
VERSION = "2.0.6".freeze | ||
VERSION = "2.1.0".freeze | ||
end |