poefy 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/poefy/generation.rb +15 -17
- data/lib/poefy/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '06059d000cd8bcb1337f205e71c7aef33d6cebc5'
|
4
|
+
data.tar.gz: 66b55d23d1ed3f633f95d40b6a5cd6f1995a4273
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09fb8bb6486cffe87fc73810e161f3760fd237e8d8c86e79606752751e3748b0914612795cbaa33215282a65274f0373d8477dd60c57a342316b242494641fc2'
|
7
|
+
data.tar.gz: dcc401e9907c144d01e4d6cb1042335669a4b762e087b6c07da576eaaab838876b2c56a1732be2643c7a5793f9280700249108564c4ca5956526a064088bae7b
|
data/lib/poefy/generation.rb
CHANGED
@@ -206,10 +206,6 @@ module Poefy
|
|
206
206
|
# words as there are lines to be matched.
|
207
207
|
rhymes = nil
|
208
208
|
|
209
|
-
# If all the lines include a 'regex' condition,
|
210
|
-
# then we can specify to only query for matching lines.
|
211
|
-
regex_all = regex_for_all line_conds
|
212
|
-
|
213
209
|
# If all the lines include a 'syllable' condition,
|
214
210
|
# then we can specify to only query for matching lines.
|
215
211
|
begin
|
@@ -226,7 +222,7 @@ module Poefy
|
|
226
222
|
# For each rhyme, get all lines and try to sastify all conditions.
|
227
223
|
out = []
|
228
224
|
rhymes.shuffle.each do |rhyme|
|
229
|
-
out = try_rhyme(conditions, rhyme, min_max,
|
225
|
+
out = try_rhyme(conditions, rhyme, min_max, line_conds)
|
230
226
|
break if !out.empty?
|
231
227
|
end
|
232
228
|
if out.empty?
|
@@ -300,14 +296,26 @@ module Poefy
|
|
300
296
|
|
301
297
|
# Loop through the rhymes until we find one that works.
|
302
298
|
# (In a reasonable time-frame)
|
303
|
-
def try_rhyme conditions, rhyme, syllable_min_max = nil,
|
299
|
+
private def try_rhyme conditions, rhyme, syllable_min_max = nil, line_conds = nil
|
304
300
|
output = []
|
305
301
|
lines = @corpus.lines_by_rhyme(rhyme, syllable_min_max)
|
306
302
|
|
307
303
|
# To reduce the number of permutations, reject lines
|
308
304
|
# that do not match any of the lines regex.
|
309
|
-
|
305
|
+
regex_conds = line_conds.map { |i| i[:regex] }
|
306
|
+
if !regex_conds.include?(nil) and !regex_conds.include?(//)
|
307
|
+
new_lines = []
|
308
|
+
[*regex_conds].each do |regex_group|
|
309
|
+
possible_lines = lines.dup
|
310
|
+
[*regex_group].each do |regex|
|
311
|
+
possible_lines.reject! { |i| !(i['line'].match(regex)) }
|
312
|
+
end
|
313
|
+
new_lines += possible_lines
|
314
|
+
end
|
315
|
+
lines = new_lines
|
316
|
+
end
|
310
317
|
|
318
|
+
# Get a sample from the lines that works for all the conditions.
|
311
319
|
begin
|
312
320
|
Timeout::timeout(2) do
|
313
321
|
output = lines.shuffle.conditional_sample(conditions)
|
@@ -334,16 +342,6 @@ module Poefy
|
|
334
342
|
min_max
|
335
343
|
end
|
336
344
|
|
337
|
-
# If every line has a regex, then return a regex union.
|
338
|
-
def regex_for_all line_conds
|
339
|
-
output = nil
|
340
|
-
if line_conds.all?{ |i| i[:regex] }
|
341
|
-
all_regex = line_conds.map{ |i| i[:regex] }
|
342
|
-
output = Regexp.union all_regex.flatten
|
343
|
-
end
|
344
|
-
output
|
345
|
-
end
|
346
|
-
|
347
345
|
end
|
348
346
|
|
349
347
|
end
|
data/lib/poefy/version.rb
CHANGED
@@ -10,7 +10,7 @@ module Poefy
|
|
10
10
|
def self.version_number
|
11
11
|
major = 1
|
12
12
|
minor = 1
|
13
|
-
tiny =
|
13
|
+
tiny = 1
|
14
14
|
pre = nil
|
15
15
|
|
16
16
|
string = [major, minor, tiny, pre].compact.join('.')
|
@@ -18,7 +18,7 @@ module Poefy
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.version_date
|
21
|
-
'2017-
|
21
|
+
'2017-11-05'
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poefy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|