gen-text 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/gen_text/vm.rb +3 -8
- metadata +2 -2
data/README.md
CHANGED
data/lib/gen_text/vm.rb
CHANGED
@@ -286,14 +286,9 @@ module GenText
|
|
286
286
|
# @param [Array<Array<(Numeric, Object)>>] weights_and_items
|
287
287
|
# @return [Array<(Numeric, Object)>]
|
288
288
|
def sample_weighed(weights_and_items)
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
weights_and_items.find do |weight, item|
|
293
|
-
current_partial_weight_sum += weight
|
294
|
-
current_partial_weight_sum > chosen_partial_weight_sum
|
295
|
-
end or
|
296
|
-
weights_and_items.last
|
289
|
+
# The algorithm is described in
|
290
|
+
# http://utopia.duth.gr/~pefraimi/research/data/2007EncOfAlg.pdf
|
291
|
+
weights_and_items.max_by { |weight, item| rand ** (1.0 / weight) }
|
297
292
|
end
|
298
293
|
|
299
294
|
def inspect_instruction(instruction)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gen-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-07-
|
12
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parse-framework
|