medieval_latina 1.3.1 → 1.4.0

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: ddadbcd35373f1f7605b245fa1be3a9cb18e739a4d7b7185a89fed9f0ffbd6d6
4
- data.tar.gz: 8bb6729f3414361eb4b07522005abb6325e118b349b31fbc3630e3ece9be94f3
3
+ metadata.gz: 01eca8c2e6d2b4f07f3c53c3e4ad5b8b8a965ac44eb4b83fd3336214ff48ee48
4
+ data.tar.gz: e937aaf342fe71e88dfdd30f4c370bb7be2ea623f769a2e0e01b96d82a7dc9a2
5
5
  SHA512:
6
- metadata.gz: 521f50400e68a172a329a019e269b5ec6f7a15f3378a2f037bda60964dab5007a12ceb160a65861d32d38500b82221042bc3006b54df878be046a9b40717e0d5
7
- data.tar.gz: 8819a9115be5efb3c864d74af27eb94df9c9f04f8199d5864a32e2cba4010b5ae4f353ddff230c05bd4d27d87ecb32b8ec5707c9ac6bcf8848207bb4e15ad9bc
6
+ metadata.gz: 320e9b86260e6cb8842da8892eeda25a1f89b61f0f13dce652089094d88f748e7921812e5fd6443a2e25def60fa8fb37cadb53aefbed266029c1421a8d7d812b
7
+ data.tar.gz: 447bbd6c1aa938a9bc21e4b75bd27c654efb0bd7378a1733c808320eaf09f6b8b01e56c7a8f28ac7b4b46d710bcdb75554605fafe4623298c909b3513d453a9a
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ fix: true
2
+ parallel: true
3
+ ruby_version: 2.6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- medieval_latina (1.3.1)
4
+ medieval_latina (1.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  class MedievalLatina
2
- VERSION = "1.3.1".freeze
2
+ VERSION = "1.4.0".freeze
3
3
  end
@@ -4,14 +4,24 @@ require "set"
4
4
 
5
5
  class MedievalLatina
6
6
  def self.[](text)
7
- prepare_text(text).map do |word|
8
- DICTIONARY[word] || new(word).call
9
- end.join(" ")
7
+ prepared_words = prepare_text(text).map do |string|
8
+ if word?(string)
9
+ DICTIONARY[string] || new(string).call
10
+ else
11
+ string
12
+ end
13
+ end
14
+
15
+ rejoin_words(prepared_words)
10
16
  end
11
17
 
12
18
  def self.prepare_text(text)
13
- text.split(" ").map do |word|
14
- prepare_word(word)
19
+ text.scan(/[\w'-]+|[[:punct:]]+/).map do |string|
20
+ if word?(string)
21
+ prepare_word(string)
22
+ else
23
+ string
24
+ end
15
25
  end
16
26
  end
17
27
 
@@ -47,10 +57,23 @@ class MedievalLatina
47
57
  NOUNS
48
58
  end
49
59
 
60
+ def self.rejoin_words(array)
61
+ array
62
+ .join(" ")
63
+ .gsub(/ +?,/, ",")
64
+ .gsub(/ +?;/, ";")
65
+ .gsub(/ +?\./, ".")
66
+ .gsub(/ +?\?/, "?")
67
+ end
68
+
50
69
  def self.verbs
51
70
  VERBS
52
71
  end
53
72
 
73
+ def self.word?(string)
74
+ string.match?(/\w/)
75
+ end
76
+
54
77
  def self.words
55
78
  ADJECTIVES | ADVERBS | Set.new(DICTIONARY.keys) | NOUNS | VERBS
56
79
  end
@@ -123,7 +146,7 @@ class MedievalLatina
123
146
 
124
147
  def initialize(text, index)
125
148
  @character = text[index]
126
- @rest = text[index + 1..-1].chars.join
149
+ @rest = text[index + 1..].chars.join
127
150
  end
128
151
 
129
152
  def to_team
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.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jayson Virissimo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-27 00:00:00.000000000 Z
11
+ date: 2023-02-02 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.
@@ -22,6 +22,7 @@ files:
22
22
  - ".github/workflows/tests.yml"
23
23
  - ".gitignore"
24
24
  - ".rspec"
25
+ - ".standard.yml"
25
26
  - ".tool-versions"
26
27
  - Gemfile
27
28
  - Gemfile.lock