medieval_latina 1.0.1 → 1.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b259ab2cbd3336a8ebca3c3eaa87dac5affc76850bf2bf8440950175d68287a3
4
- data.tar.gz: 89d42056ed9504d4e683b08295a63248fb2e97a6f7a62b1f81148e09824871f8
3
+ metadata.gz: eeadae0d7186cfad50f2d28d93f76f7da6d4d2095ece5f196bc7169dcfc1d565
4
+ data.tar.gz: 92417f4f06c39f0c5a9fe82533e7a310987f82d10f99a5f69bbd947b90aaa794
5
5
  SHA512:
6
- metadata.gz: bf736dd6b6ff68a479a93b5ebd64643ddd9cf647c39eef1c52b7da20630fcfb0920d08e7b062ea5ae6b8b34f210666591229c2a21b62bd2675e96fc77fedf173
7
- data.tar.gz: c2cb0bc3b0a0c5ba85ef0257eb1a424e95e3acee7f1f0ee0dbcffd4132e41208ee18e588016e8379493b81d1509a1fdb783f7bf1116a89b67da967ffe889c450
6
+ metadata.gz: ff38b976d3566f3c8405bef715f43a15ee8669959e053e7cd25a419dfea1da673c3b7978d6212c119e20ca4b75537af8811fd30c4e43f004fd8bb5e5a6d796d8
7
+ data.tar.gz: 7e77ad6eac2f72cfbdd4e09fda79c1d11e204107c11b7e4ca4de782027c1f792cdf39e427ffecbd7a7438d4a5f0cdd720c97c2a478120a8172d522381040e63b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- medieval_latina (1.0.1)
4
+ medieval_latina (1.0.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # MedievalLatina
2
2
 
3
3
  There are good text-to-speech engines for English and classical Latin, but none for medieval Latin.
4
- `MedievalLatina` converts Latin text to a kind of phonetic spelling that can be read by English text-to-speech engines.
4
+ `MedievalLatina` converts Latin text to a kind of phonetic spelling that can be read by English language text-to-speech engines.
5
5
 
6
6
  ## Installation
7
7
 
@@ -35,7 +35,7 @@ Then, run `rake spec` to run the tests.
35
35
  You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
36
 
37
37
  To install this gem onto your local machine, run `bundle exec rake install`.
38
- To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+ To release a new version, update the version number in `version.rb`, run `bin/setup` to increment the version in the lock file, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
39
  Run `standardrb --fix` before submitting any changes, to help keep the code formatting uniform.
40
40
 
41
41
  ## Contributing
@@ -1,22 +1,24 @@
1
+ require "medieval_latina/dictionary"
1
2
  require "medieval_latina/version"
2
3
 
3
4
  class MedievalLatina
4
5
  def self.[](text)
5
- new(text).call
6
+ text.split(" ").map { |word|
7
+ DICTIONARY[word.downcase] || new(word).call
8
+ }.join(" ")
6
9
  end
7
10
 
8
- def initialize(text)
11
+ def initialize(word)
9
12
  @index = 0
10
- @text = text
13
+ @word = word
11
14
  end
12
15
 
13
16
  def call
14
17
  array = []
15
18
 
16
- until index >= text.length
17
- character = text[index]
18
- rest = text.chars.drop(index + 1).join
19
- result = vowel(character, rest.chars.first) || consonent(character, rest)
19
+ until index >= word.length
20
+ substring = Substring.new(word, index)
21
+ result = vowel(substring) || consonant(substring) || Result.new(substring.character, 1)
20
22
  array.push(result.substring)
21
23
  self.index = index + result.increment_by
22
24
  end
@@ -27,39 +29,38 @@ class MedievalLatina
27
29
  private
28
30
 
29
31
  attr_accessor :index
30
- attr_reader :text
32
+ attr_reader :word
31
33
 
32
34
  CONSONENTS = {
33
35
  c: ->(rest) { SOFT_C.any? { |item| rest.start_with?(item) } ? "ch" : "k" },
34
36
  g: ->(rest) { SOFT_G.any? { |item| rest.start_with?(item) } ? "j" : "g" },
35
- j: ->(rest) { "y" }
37
+ j: ->(rest) { "y" },
38
+ x: ->(rest) { "ks" }
36
39
  }
37
40
  CONSONENT_TEAMS = {qu: "kw"}
38
41
  SOFT_C = ["e", "i", "ae", "oe"]
39
42
  SOFT_G = SOFT_C
40
- VOWEL_TEAMS = {ae: "ay", oe: "ay", au: "ow"}
43
+ VOWEL_TEAMS = {ae: "ay", oe: "ay", au: "ou"}
41
44
  VOWELS = {a: "ah", e: "ay", i: "ee", o: "oh", u: "oo"}
42
45
 
43
46
  Result = Struct.new(:substring, :increment_by)
44
47
 
45
- def consonent(character, rest)
46
- consonent_team = CONSONENT_TEAMS["#{character}#{rest.chars.first}".intern]
47
- consonent = if CONSONENTS.key?(character.intern)
48
- CONSONENTS[character.intern].call(rest)
49
- else
50
- character
48
+ def consonant(substring)
49
+ consonant_team = CONSONENT_TEAMS[substring.to_team]
50
+ consonant = if CONSONENTS.key?(substring.character.intern)
51
+ CONSONENTS[substring.character.intern].call(substring.rest)
51
52
  end
52
53
 
53
- if consonent_team
54
- Result.new(consonent_team, 2)
55
- elsif consonent
56
- Result.new(consonent, 1)
54
+ if consonant_team
55
+ Result.new(consonant_team, 2)
56
+ elsif consonant
57
+ Result.new(consonant, 1)
57
58
  end
58
59
  end
59
60
 
60
- def vowel(character, next_character)
61
- vowel_team = VOWEL_TEAMS["#{character}#{next_character}".intern]
62
- vowel = VOWELS[character.intern]
61
+ def vowel(substring)
62
+ vowel_team = VOWEL_TEAMS[substring.to_team]
63
+ vowel = VOWELS[substring.character.intern]
63
64
 
64
65
  if vowel_team
65
66
  Result.new(vowel_team, 2)
@@ -68,5 +69,18 @@ class MedievalLatina
68
69
  end
69
70
  end
70
71
 
72
+ class Substring
73
+ attr_reader :character, :rest
74
+
75
+ def initialize(text, index)
76
+ @character = text[index]
77
+ @rest = text.chars.drop(index + 1).join
78
+ end
79
+
80
+ def to_team
81
+ "#{character}#{rest.chars.first}".intern
82
+ end
83
+ end
84
+
71
85
  class Error < StandardError; end
72
86
  end
@@ -0,0 +1,8 @@
1
+ class MedievalLatina
2
+ DICTIONARY = {
3
+ "ex" => "ex",
4
+ "duo" => "doo-oh",
5
+ "octo" => "awk-toh",
6
+ "quo" => "quo"
7
+ }.freeze
8
+ end
@@ -1,3 +1,3 @@
1
1
  class MedievalLatina
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.6"
3
3
  end
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: 1.0.1
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jayson Virissimo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-18 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  There are good text-to-speech engines for English and classical Latin, but none for medieval Latin.
@@ -30,6 +30,7 @@ files:
30
30
  - bin/console
31
31
  - bin/setup
32
32
  - lib/medieval_latina.rb
33
+ - lib/medieval_latina/dictionary.rb
33
34
  - lib/medieval_latina/version.rb
34
35
  - medieval_latina.gemspec
35
36
  homepage: https://github.com/jaysonvirissimo/medieval_latina