jekyll-chatgpt-translate 0.0.36 → 0.0.37

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: 297a8b46d6e777cfc060956768b7807acf69b4fa1f52c65f4fbed3a0084c6268
4
- data.tar.gz: a81769edc12e05ad6aecb14b31bdec6ee2dcdc797ee27e6e3d8b03f8dc4c975a
3
+ metadata.gz: c0f1eb7be508b40853f8fc04d94cd0c6f30ddfe2be81b6d3fc7f6a45101d10b1
4
+ data.tar.gz: cb4d6e55f8d93e00307135f52cfba873a7ece62a01cb785f0d0e4ada293aaa20
5
5
  SHA512:
6
- metadata.gz: ebb2e3a583e2d2e0282b6d89ad09479aebd33c62b5fa20ae681d89a2b864dfb9f4af6e2d293e8c3817225331e1a47a6196014b9ee4f2b9080f04b3146a1fe738
7
- data.tar.gz: dcf28aec1603c0b2cece95fe06085e3fe028e288bf1ca60a3388405395906df5a5a123dc0b23e8146bc3689ec82d0b96baece8744f8c003b0f89b87a43ed5e3b
6
+ metadata.gz: 053d40f293680a7b4ec3f78f5b09b1ddef17183b1dbfce93ab10fffca3cbb1b1384644e4da3377c5c1abc0ff96fdb1b55d8f58d7e30788aa7ddeba44dc6e0d65
7
+ data.tar.gz: 0cc7dd560f374a400b8c8ff2b7782daca793a2db48eac1fc698806506f0341713751241a2feb739d485145efbe57ba6c5d2d43d188208fa0e8142993447a6928
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
29
29
  s.required_ruby_version = '>= 2.6'
30
30
  s.name = 'jekyll-chatgpt-translate'
31
- s.version = '0.0.36'
31
+ s.version = '0.0.37'
32
32
  s.license = 'MIT'
33
33
  s.summary = 'Translate Jekyll Pages Through ChatGPT'
34
34
  s.description = [
@@ -51,7 +51,7 @@ class GptTranslate::ChatGPT
51
51
  @target = target
52
52
  end
53
53
 
54
- def translate(markdown, min: 32)
54
+ def translate(markdown, min: 32, window_length: 2000)
55
55
  pars = GptTranslate::Pars.new(markdown).to_a
56
56
  ready = []
57
57
  later = []
@@ -82,17 +82,23 @@ class GptTranslate::ChatGPT
82
82
  later[i] = par
83
83
  end
84
84
  end
85
- accum = []
86
- (0..pars.length).each do |i|
87
- if !ready[i].nil? && !accum.empty? && later[i].nil?
88
- ready[i - 1] = translate_pars(accum)
89
- accum = []
85
+ out = []
86
+ i = 0
87
+ while i < pars.length
88
+ unless ready[i].nil?
89
+ out << ready[i]
90
+ i += 1
90
91
  next
91
92
  end
92
- accum << later[i] unless later[i].nil?
93
+ accum = []
94
+ until later[i].nil?
95
+ accum << later[i]
96
+ break if accum.join.split.count > window_length
97
+ i += 1
98
+ end
99
+ out << translate_pars(accum)
93
100
  end
94
- ready[pars.length - 1] = translate_pars(accum) unless accum.empty?
95
- ready.join("\n\n")
101
+ out.join("\n\n")
96
102
  end
97
103
 
98
104
  private
@@ -23,5 +23,5 @@
23
23
  # SOFTWARE.
24
24
 
25
25
  module GptTranslate
26
- VERSION = '0.0.36'
26
+ VERSION = '0.0.37'
27
27
  end
data/test/test_chatgpt.rb CHANGED
@@ -76,7 +76,8 @@ class GptTranslate::ChatGPTTest < Minitest::Test
76
76
 
77
77
  This is it.
78
78
  ",
79
- min: 40
79
+ min: 40,
80
+ window_length: 10
80
81
  )
81
82
  end
82
83
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-chatgpt-translate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.36
4
+ version: 0.0.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-29 00:00:00.000000000 Z
11
+ date: 2023-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: humanize