text-gen 0.13.2 → 0.13.4
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 +4 -4
- data/lib/text/gen/context.rb +6 -2
- data/lib/text/gen/filter/distinct.rb +2 -2
- data/lib/text/gen/filter/remember.rb +2 -2
- data/lib/text/gen/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a89e9918a7f7feb924839507c942523f6a765faf4374c2e8c68919c87e98be62
|
|
4
|
+
data.tar.gz: 63dc2c142d41e7c3e83b07bfaf1549ef348651ec29ddb2c06516878bed7e4780
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d56e45920ff31deff8c73c86f4c4f845028268863a18a4f86501ecaf5023998d702c7d4948076af5ce5bec8f4a948bb3d63f0387c368c1e041756c8a13ae70d5
|
|
7
|
+
data.tar.gz: 8f452deb1b88360ca9f2f7e83ab202192d822ef3b87a6811ce5229c40aeff37262f000a63b004a8d772900888368b1db41083f290082a83cda681e4beedc478a
|
data/lib/text/gen/context.rb
CHANGED
|
@@ -60,6 +60,10 @@ module Text
|
|
|
60
60
|
@keys.last
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
+
def current_key_without_category
|
|
64
|
+
current_key.split(">")&.last
|
|
65
|
+
end
|
|
66
|
+
|
|
63
67
|
def current_strategy
|
|
64
68
|
@strategy_stack.last&.first || "weighted"
|
|
65
69
|
end
|
|
@@ -69,12 +73,12 @@ module Text
|
|
|
69
73
|
end
|
|
70
74
|
|
|
71
75
|
def remember(result)
|
|
72
|
-
@remembered << [
|
|
76
|
+
@remembered << [current_key_without_category, result]
|
|
73
77
|
result
|
|
74
78
|
end
|
|
75
79
|
|
|
76
80
|
def remembered(key = nil)
|
|
77
|
-
key ||=
|
|
81
|
+
key ||= current_key_without_category
|
|
78
82
|
@remembered.select { |k, _r| k == key }.map(&:last)
|
|
79
83
|
end
|
|
80
84
|
|
|
@@ -6,9 +6,9 @@ module Text
|
|
|
6
6
|
# Return nil if the text value has already been generated
|
|
7
7
|
class Distinct < Base
|
|
8
8
|
def result(context, result)
|
|
9
|
-
return result if key != context.current_key
|
|
9
|
+
return result if key != context.current_key && key != context.current_key_without_category
|
|
10
10
|
|
|
11
|
-
previous = context.remembered
|
|
11
|
+
previous = context.remembered
|
|
12
12
|
return if previous.any? { |r| r.text.strip.downcase == result.text.strip.downcase }
|
|
13
13
|
|
|
14
14
|
result
|
|
@@ -5,9 +5,9 @@ module Text
|
|
|
5
5
|
module Filter
|
|
6
6
|
class Remember < Base
|
|
7
7
|
def result(context, result)
|
|
8
|
-
return result if key != context.current_key
|
|
8
|
+
return result if key != context.current_key && key != context.current_key_without_category
|
|
9
9
|
|
|
10
|
-
previous = context.remembered
|
|
10
|
+
previous = context.remembered
|
|
11
11
|
return previous.sample unless previous.nil? || previous.empty?
|
|
12
12
|
|
|
13
13
|
result
|
data/lib/text/gen/version.rb
CHANGED