medieval_latina 2.1.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73b3e247e6a3cd36e70b64ebffb4d4947f2f3f343a8749693269c32e6dd5f64b
4
- data.tar.gz: 21652459415b9160232035ca7a355dc0f4c1ffac0848f59b5793858e9c41fc0c
3
+ metadata.gz: 0dd902526791ea82b288d966db1bf6ac699ca6846256412aa60c9b685253e333
4
+ data.tar.gz: 9abfa510fa6c2f3dbc21b4e90b0392addc45a932c244d39cc6434ca46a810639
5
5
  SHA512:
6
- metadata.gz: 5a2be43d8e45015049f7fd448626ff3800706c7b5b98f1792fe902788c2ba7a6d5a3c80d5e59d0415319f7432275d8eeaea294ad167e187486d07ab580128f79
7
- data.tar.gz: aba3e38916bc44b9603fd50fd27dd4c3ea94a0a7e23b46a5201f334b73c045019082fa9a2cd45970fa1891a6f50daf95b0caacee8066a3e72e8c8f39fc27a14a
6
+ metadata.gz: 60e4c5925a37ac2ccc8e08ffcefd35a0d61cb8e4b46c81d1298d703dc31791b3ff7d7aabf828533d3e82842d5867eb7cc5a4aaee4422d6de4fc75f733aa58566
7
+ data.tar.gz: 5822082352ae540e0aa67b49ad2b20f3744502c36dcb7ec96d696fd76bd1469a31a0210901caddd76a21189abecf682a129a1a094e84c3c100e52a3e1166140a
@@ -1,4 +1,4 @@
1
- name: Tests
1
+ name: Tests and Linting
2
2
 
3
3
  on:
4
4
  pull_request:
@@ -11,7 +11,7 @@ on:
11
11
  jobs:
12
12
  unit_tests:
13
13
  name: Unit Tests
14
- if: "contains(github.event.commits[0].message, '[ci skip]') == false"
14
+ if: ${{ ! contains(github.event.head_commit.message, '[ci skip]') }}
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
@@ -19,16 +19,11 @@ jobs:
19
19
  - macos
20
20
  - ubuntu
21
21
  ruby:
22
- - 2.7
23
- - 3.0
24
- - 3.1
25
- - 3.2
22
+ - '3.2'
23
+ - '3.3'
24
+ - '3.4'
26
25
  allow_failures:
27
26
  - false
28
- include:
29
- - os: ubuntu
30
- ruby: ruby-head
31
- allow_failures: true
32
27
  env:
33
28
  BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
34
29
  ALLOW_FAILURES: "${{ matrix.allow_failures }}"
@@ -36,7 +31,7 @@ jobs:
36
31
  continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
37
32
  steps:
38
33
  - name: Checkout
39
- uses: actions/checkout@v2
34
+ uses: actions/checkout@v3
40
35
  - name: Setup Ruby
41
36
  uses: ruby/setup-ruby@v1
42
37
  with:
@@ -44,3 +39,22 @@ jobs:
44
39
  bundler-cache: true
45
40
  - name: Test
46
41
  run: bundle exec rake spec || $ALLOW_FAILURES
42
+
43
+
44
+ lint:
45
+ name: Linting
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - name: Checkout
49
+ uses: actions/checkout@v3
50
+ - name: Setup Ruby
51
+ uses: ruby/setup-ruby@v1
52
+ with:
53
+ ruby-version: '3.4'
54
+ bundler-cache: true
55
+ - name: Install dependencies
56
+ run: bundle install
57
+ - name: Lint Ruby
58
+ run: bundle exec standardrb
59
+ - name: Lint JSON
60
+ run: bundle exec jsonlint data/dictionary.json
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .DS_Store
data/.standard.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  fix: true
2
2
  parallel: true
3
- ruby_version: 2.6
3
+ ruby_version: 3.2
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.2.0
1
+ ruby 3.4.1
data/Gemfile CHANGED
@@ -2,9 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in medieval_latina.gemspec
4
4
  gemspec
5
-
6
- gem "i18n"
7
- gem "rake", "~> 12.0"
8
- gem "rspec", "~> 3.0"
9
- gem "builder", group: [:development, :test]
10
- gem "standard", group: [:development, :test]
data/Gemfile.lock CHANGED
@@ -1,24 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- medieval_latina (2.1.1)
4
+ medieval_latina (3.1.0)
5
5
  i18n
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.0)
11
- builder (3.2.4)
10
+ ast (2.4.2)
11
+ bigdecimal (3.1.8)
12
12
  concurrent-ruby (1.2.2)
13
13
  diff-lcs (1.3)
14
14
  i18n (1.13.0)
15
15
  concurrent-ruby (~> 1.0)
16
- parallel (1.19.1)
17
- parser (2.7.1.2)
18
- ast (~> 2.4.0)
19
- rainbow (3.0.0)
16
+ json (2.7.2)
17
+ jsonlint (0.4.0)
18
+ oj (~> 3)
19
+ optimist (~> 3)
20
+ language_server-protocol (3.17.0.3)
21
+ lint_roller (1.1.0)
22
+ mini_portile2 (2.8.6)
23
+ nokogiri (1.18.0)
24
+ mini_portile2 (~> 2.8.2)
25
+ racc (~> 1.4)
26
+ oj (3.16.5)
27
+ bigdecimal (>= 3.0)
28
+ ostruct (>= 0.2)
29
+ optimist (3.1.0)
30
+ ostruct (0.6.0)
31
+ parallel (1.26.1)
32
+ parser (3.3.4.2)
33
+ ast (~> 2.4.1)
34
+ racc
35
+ racc (1.7.3)
36
+ rainbow (3.1.1)
20
37
  rake (12.3.3)
21
- rexml (3.2.5)
38
+ regexp_parser (2.9.2)
39
+ rexml (3.3.9)
22
40
  rspec (3.9.0)
23
41
  rspec-core (~> 3.9.0)
24
42
  rspec-expectations (~> 3.9.0)
@@ -32,31 +50,49 @@ GEM
32
50
  diff-lcs (>= 1.2.0, < 2.0)
33
51
  rspec-support (~> 3.9.0)
34
52
  rspec-support (3.9.3)
35
- rubocop (0.83.0)
53
+ rubocop (1.64.1)
54
+ json (~> 2.3)
55
+ language_server-protocol (>= 3.17.0)
36
56
  parallel (~> 1.10)
37
- parser (>= 2.7.0.1)
57
+ parser (>= 3.3.0.2)
38
58
  rainbow (>= 2.2.2, < 4.0)
39
- rexml
59
+ regexp_parser (>= 1.8, < 3.0)
60
+ rexml (>= 3.2.5, < 4.0)
61
+ rubocop-ast (>= 1.31.1, < 2.0)
40
62
  ruby-progressbar (~> 1.7)
41
- unicode-display_width (>= 1.4.0, < 2.0)
42
- rubocop-performance (1.5.2)
43
- rubocop (>= 0.71.0)
44
- ruby-progressbar (1.10.1)
45
- standard (0.4.2)
46
- rubocop (~> 0.83.0)
47
- rubocop-performance (~> 1.5.2)
48
- unicode-display_width (1.7.0)
63
+ unicode-display_width (>= 2.4.0, < 3.0)
64
+ rubocop-ast (1.32.0)
65
+ parser (>= 3.3.1.0)
66
+ rubocop-performance (1.21.1)
67
+ rubocop (>= 1.48.1, < 2.0)
68
+ rubocop-ast (>= 1.31.1, < 2.0)
69
+ ruby-progressbar (1.13.0)
70
+ standard (1.39.2)
71
+ language_server-protocol (~> 3.17.0.2)
72
+ lint_roller (~> 1.0)
73
+ rubocop (~> 1.64.0)
74
+ standard-custom (~> 1.0.0)
75
+ standard-performance (~> 1.4)
76
+ standard-custom (1.0.2)
77
+ lint_roller (~> 1.0)
78
+ rubocop (~> 1.50)
79
+ standard-performance (1.4.0)
80
+ lint_roller (~> 1.1)
81
+ rubocop-performance (~> 1.21.0)
82
+ standardrb (1.0.1)
83
+ standard
84
+ unicode-display_width (2.5.0)
49
85
 
50
86
  PLATFORMS
51
87
  ruby
52
88
 
53
89
  DEPENDENCIES
54
- builder
55
- i18n
90
+ jsonlint
56
91
  medieval_latina!
92
+ nokogiri
57
93
  rake (~> 12.0)
58
94
  rspec (~> 3.0)
59
- standard
95
+ standardrb
60
96
 
61
97
  BUNDLED WITH
62
98
  2.4.1
data/README.md CHANGED
@@ -21,12 +21,57 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
+ ### Help English language text-to-speech engines pronounce Latin
24
25
  ```ruby
25
26
  ["caelum", "omnia", "pugno"].each { |word| puts MedievalLatina[word] }
26
27
  => "chayloom"
27
28
  => "ohm-nia"
28
29
  => "poon-yoh"
29
30
 
31
+ sentence = MedievalLatina["sed libera nos a malo"]
32
+ => "sayd leebayrah nohs ah mahloh"
33
+ ```
34
+ ```javascript
35
+ let sentence = "...";
36
+ responsiveVoice.speak(sentence, "UK English Female");
37
+ ```
38
+ ### Generate lexicons to override text-to-speech pronunciation
39
+ ```ruby
40
+ polly = Aws::Polly::Client.new
41
+ s3 = Aws::S3::Client.new
42
+
43
+ sentence = "PATER NOSTER qui es in caelis"
44
+
45
+ words = sentence.split(" ")
46
+ pronunciations = MedievalLatina.pronunciations_for(words)
47
+ lexicon = MedievalLatina::LexiconBuilder.new(pronunciations).call
48
+
49
+ name = "CustomLatin"
50
+ polly.put_lexicon(name: name, content: lexicon.to_s)
51
+
52
+ # Synthesize speech using the lexicons
53
+ response = polly.synthesize_speech(
54
+ lexicon_names: [name],
55
+ text: sentence,
56
+ output_format: "mp3",
57
+ voice_id: "Joanna"
58
+ )
59
+
60
+ # Read the audio data and store it in a variable
61
+ audio_data = response.audio_stream.read
62
+
63
+ bucket_name = "foo"
64
+ object_key = "bar/pater-noster.mp3"
65
+
66
+ s3.put_object(
67
+ bucket: bucket_name,
68
+ key: object_key,
69
+ body: audio_data
70
+ )
71
+ ```
72
+
73
+ ### Latin langauge helper methods
74
+ ```ruby
30
75
  MedievalLatina.verb?("voco")
31
76
  => true
32
77
 
@@ -48,6 +93,7 @@ MedievalLatina.noun?("canis")
48
93
  After checking out the repo, run `bin/setup` to install dependencies.
49
94
  Then, run `rake spec` to run the tests.
50
95
  You can also run `bin/console` for an interactive prompt that will allow you to experiment.
96
+ Maintain project style by running `bin/lint` before commiting changes.
51
97
 
52
98
  To install this gem onto your local machine, run `bundle exec rake install`.
53
99
 
@@ -56,13 +102,13 @@ To release a new version:
56
102
  2. Run `bin/setup` to increment the version in the lock file
57
103
  3. Run `bundle exec rake release`
58
104
 
59
- Rebuild the lexicon file when you add new International Phonetic Alphabet pronunciations.
105
+ Rebuild the lexicon files when you add new International Phonetic Alphabet pronunciations.
60
106
  You do this by running: `bin/build`
61
107
 
62
108
  ## Contributing
63
109
 
64
110
  Bug reports and pull requests are welcome on GitHub at https://github.com/jaysonvirissimo/medieval_latina.
65
- Run `standardrb --fix` before submitting any changes, to help keep the code formatting uniform.
111
+ Run `bin/lint` before submitting any changes, to help keep the code formatting uniform.
66
112
 
67
113
  ## License
68
114
 
data/bin/build CHANGED
@@ -1,7 +1,34 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'json'
3
4
  require "bundler/setup"
4
5
  require "medieval_latina"
5
6
  require "medieval_latina/lexicon_builder"
6
7
 
7
- MedievalLatina::LexiconBuilder.write
8
+ def create_pls_file(file_path, words)
9
+ document = MedievalLatina::LexiconBuilder.new(words).call
10
+
11
+ File.open(file_path, 'w') do |file|
12
+ document.write(file, 2)
13
+ file.write("\n")
14
+ end
15
+ end
16
+
17
+ file_path = File.join(File.dirname(__FILE__), '..', 'data', 'dictionary.json')
18
+ pronunciation_guide = JSON
19
+ .parse(File.read(file_path))
20
+ .each_with_object({}) do |(word, metadata), hash|
21
+ if metadata["ipa"]
22
+ hash[word] = metadata["ipa"]
23
+ end
24
+ end
25
+
26
+ # Split the words across multiple PLS files
27
+ lexicons_dir = File.join(File.dirname(__FILE__), '..', 'lexicons')
28
+ size = pronunciation_guide.size
29
+ number = size / 256
30
+ fraction = size / number
31
+ pronunciation_guide.each_slice(fraction).to_a.each_with_index do |array, index|
32
+ formatted_index = sprintf("%02d", index)
33
+ create_pls_file(File.join(lexicons_dir, "Latin#{formatted_index}.pls"), array.to_h)
34
+ end
data/bin/lint ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ # Run StandardRB to lint Ruby files
7
+ echo "Linting Ruby files with StandardRB..."
8
+ bundle exec standardrb
9
+
10
+ # Run jsonlint to check the dictionary.json file
11
+ echo "Linting dictionary.json with jsonlint..."
12
+ bundle exec jsonlint data/dictionary.json
13
+
14
+ echo "Linting completed."