rank-aggregation 0.0.1
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.
- data/README.markdown +22 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/bin/rank +34 -0
- data/lib/rank-aggregation.rb +14 -0
- data/lib/rank-aggregation/markov.rb +35 -0
- data/lib/rank-aggregation/ordering.rb +44 -0
- data/lib/rank-aggregation/ranker.rb +115 -0
- data/lib/rank-aggregation/scorer.rb +41 -0
- data/notes/algorithm.markdown +52 -0
- data/rank-aggregation.gemspec +62 -0
- data/samples/clear-with-noise +35 -0
- data/samples/languages +1000 -0
- data/samples/pairs +14850 -0
- data/samples/random +1000 -0
- data/scores +4 -0
- data/spec/helper.rb +4 -0
- data/spec/rank-aggregation_spec.rb +30 -0
- metadata +98 -0
data/scores
ADDED
data/spec/helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe RankAggregation do
|
4
|
+
it "should aggregate a single rank into itself" do
|
5
|
+
r = (1..10).to_a
|
6
|
+
RankAggregation.combine_rankings([r]).should == r
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
it "should elect the condorcet winner" do
|
11
|
+
RankAggregation.combine_rankings([
|
12
|
+
[1, 2, 3],
|
13
|
+
[1, 3, 2]
|
14
|
+
])[0].should == 1
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should go with the greater majority in cases of ambiguity" do
|
18
|
+
a = [1, 2, 3]
|
19
|
+
b = [2, 3, 1]
|
20
|
+
c = [3, 1, 2]
|
21
|
+
|
22
|
+
r1 = [a] * 11 + [b] * 10 + [c] * 10
|
23
|
+
r2 = [a] * 10 + [b] * 11 + [c] * 10
|
24
|
+
r3 = [a] * 10 + [b] * 10 + [c] * 11
|
25
|
+
|
26
|
+
RankAggregation.combine_rankings(r1).should == a
|
27
|
+
RankAggregation.combine_rankings(r2).should == b
|
28
|
+
RankAggregation.combine_rankings(r3).should == c
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rank-aggregation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- David R. MacIver
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-20 00:00:00 +01:00
|
19
|
+
default_executable: rank
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: trollop
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description:
|
36
|
+
email: david@drmaciver.com
|
37
|
+
executables:
|
38
|
+
- rank
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README.markdown
|
43
|
+
files:
|
44
|
+
- README.markdown
|
45
|
+
- Rakefile
|
46
|
+
- VERSION
|
47
|
+
- bin/rank
|
48
|
+
- lib/rank-aggregation.rb
|
49
|
+
- lib/rank-aggregation/markov.rb
|
50
|
+
- lib/rank-aggregation/ordering.rb
|
51
|
+
- lib/rank-aggregation/ranker.rb
|
52
|
+
- lib/rank-aggregation/scorer.rb
|
53
|
+
- notes/algorithm.markdown
|
54
|
+
- rank-aggregation.gemspec
|
55
|
+
- samples/clear-with-noise
|
56
|
+
- samples/languages
|
57
|
+
- samples/pairs
|
58
|
+
- samples/random
|
59
|
+
- scores
|
60
|
+
- spec/helper.rb
|
61
|
+
- spec/rank-aggregation_spec.rb
|
62
|
+
has_rdoc: true
|
63
|
+
homepage: http://github.com/DRMacIver/rank-aggregation
|
64
|
+
licenses: []
|
65
|
+
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options:
|
68
|
+
- --charset=UTF-8
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.3.7
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: Turn a collection of individual preferences on items into an aggregate rank for those preferences
|
96
|
+
test_files:
|
97
|
+
- spec/rank-aggregation_spec.rb
|
98
|
+
- spec/helper.rb
|