apriori 0.2.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/History.txt +16 -0
- data/License.txt +20 -0
- data/Manifest.txt +121 -0
- data/README.txt +149 -0
- data/Rakefile +15 -0
- data/TODO.txt +60 -0
- data/attic/c_ext_test1/MyTest/MyTest.c +23 -0
- data/attic/c_ext_test1/MyTest/extconf.rb +11 -0
- data/attic/c_ext_test1/mytest.rb +10 -0
- data/attic/test.c +12 -0
- data/config/hoe.rb +81 -0
- data/config/requirements.rb +29 -0
- data/examples/01_simple_example.rb +32 -0
- data/examples/02_small_file_example.rb +17 -0
- data/examples/03_large_file_example.rb +22 -0
- data/examples/test_data/market_basket_basic_test.dat +9 -0
- data/ext/Apriori.c +149 -0
- data/ext/Makefile +149 -0
- data/ext/apriori/doc/apriori.html +1301 -0
- data/ext/apriori/doc/arem.gp +68 -0
- data/ext/apriori/doc/c_rev.gp +89 -0
- data/ext/apriori/doc/chi2.tex +156 -0
- data/ext/apriori/doc/copying +504 -0
- data/ext/apriori/doc/line.gif +0 -0
- data/ext/apriori/doc/uparrow.gif +0 -0
- data/ext/apriori/ex/flg2set +15 -0
- data/ext/apriori/ex/hdr2set +13 -0
- data/ext/apriori/ex/readme +71 -0
- data/ext/apriori/ex/row2set +7 -0
- data/ext/apriori/ex/rulesort +24 -0
- data/ext/apriori/ex/tab2set +9 -0
- data/ext/apriori/ex/test.app +2 -0
- data/ext/apriori/ex/test.rul +9 -0
- data/ext/apriori/ex/test1.rul +43 -0
- data/ext/apriori/ex/test1.tab +10 -0
- data/ext/apriori/ex/test2.tab +10 -0
- data/ext/apriori/ex/test3.tab +30 -0
- data/ext/apriori/ex/test4.tab +11 -0
- data/ext/apriori/ex/test5.tab +39 -0
- data/ext/apriori/ex/tid2set +23 -0
- data/ext/apriori/ex/xhdr2set +33 -0
- data/ext/apriori/src/apriori.c +750 -0
- data/ext/apriori/src/apriori.dsp +120 -0
- data/ext/apriori/src/apriori.dsw +29 -0
- data/ext/apriori/src/apriori.mak +99 -0
- data/ext/apriori/src/istree.c +1411 -0
- data/ext/apriori/src/istree.h +160 -0
- data/ext/apriori/src/makefile +105 -0
- data/ext/apriori/src/tract.c +870 -0
- data/ext/apriori/src/tract.h +261 -0
- data/ext/apriori_wrapper.c +757 -0
- data/ext/apriori_wrapper.h +10 -0
- data/ext/extconf.rb +32 -0
- data/ext/math/doc/copying +504 -0
- data/ext/math/src/chi2.c +151 -0
- data/ext/math/src/chi2.h +27 -0
- data/ext/math/src/choose.c +71 -0
- data/ext/math/src/choose.h +16 -0
- data/ext/math/src/gamma.c +446 -0
- data/ext/math/src/gamma.h +39 -0
- data/ext/math/src/intexp.c +35 -0
- data/ext/math/src/intexp.h +15 -0
- data/ext/math/src/makefile +164 -0
- data/ext/math/src/math.mak +48 -0
- data/ext/math/src/normal.c +387 -0
- data/ext/math/src/normal.h +44 -0
- data/ext/math/src/radfn.c +113 -0
- data/ext/math/src/radfn.h +34 -0
- data/ext/math/src/zeta.c +49 -0
- data/ext/math/src/zeta.h +15 -0
- data/ext/pre-clean.rb +8 -0
- data/ext/pre-setup.rb +9 -0
- data/ext/util/doc/copying +504 -0
- data/ext/util/src/listops.c +76 -0
- data/ext/util/src/listops.h +26 -0
- data/ext/util/src/makefile +103 -0
- data/ext/util/src/memsys.c +84 -0
- data/ext/util/src/memsys.h +42 -0
- data/ext/util/src/nstats.c +288 -0
- data/ext/util/src/nstats.h +69 -0
- data/ext/util/src/params.c +86 -0
- data/ext/util/src/params.h +19 -0
- data/ext/util/src/parse.c +133 -0
- data/ext/util/src/parse.h +81 -0
- data/ext/util/src/scan.c +767 -0
- data/ext/util/src/scan.h +111 -0
- data/ext/util/src/symtab.c +443 -0
- data/ext/util/src/symtab.h +121 -0
- data/ext/util/src/tabscan.c +279 -0
- data/ext/util/src/tabscan.h +99 -0
- data/ext/util/src/util.mak +91 -0
- data/ext/util/src/vecops.c +317 -0
- data/ext/util/src/vecops.h +42 -0
- data/lib/apriori.rb +133 -0
- data/lib/apriori/adapter.rb +13 -0
- data/lib/apriori/association_rule.rb +89 -0
- data/lib/apriori/version.rb +9 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/tasks/apriori.rake +20 -0
- data/tasks/attic.rake +28 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/install.rake +13 -0
- data/tasks/website.rake +17 -0
- data/test/apriori_test.rb +13 -0
- data/test/fixtures/market_basket_results_test.txt +5 -0
- data/test/fixtures/market_basket_string_test.txt +7 -0
- data/test/fixtures/results.txt +2 -0
- data/test/fixtures/sample.txt +7 -0
- data/test/test_helper.rb +5 -0
- data/test/unit/test_apriori.rb +68 -0
- data/test/unit/test_itemsets_and_parsing.rb +82 -0
- data/website/index.html +248 -0
- data/website/index.txt +152 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +142 -0
- data/website/template.html.erb +49 -0
- metadata +226 -0
data/config/hoe.rb
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require 'apriori/version'
|
|
2
|
+
|
|
3
|
+
AUTHOR = 'Nate Murray' # can also be an array of Authors
|
|
4
|
+
EMAIL = "nate@natemurray.com"
|
|
5
|
+
DESCRIPTION = "Ruby Apriori is a library to efficiently find item association rules within large sets of transactions."
|
|
6
|
+
GEM_NAME = 'apriori' # what ppl will type to install your gem
|
|
7
|
+
RUBYFORGE_PROJECT = 'apriori' # The unix name for your project
|
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
|
10
|
+
EXTRA_DEPENDENCIES = [
|
|
11
|
+
# ['activesupport', '>= 1.3.1']
|
|
12
|
+
['rake', '>= 0.0.0'],
|
|
13
|
+
['hoe', '>= 0.0.0'],
|
|
14
|
+
['newgem', '>= 0.0.0'],
|
|
15
|
+
['rubigen', '>= 0.0.0']
|
|
16
|
+
] # An array of rubygem dependencies [name, version]
|
|
17
|
+
|
|
18
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
|
19
|
+
@config = nil
|
|
20
|
+
RUBYFORGE_USERNAME = "unknown"
|
|
21
|
+
def rubyforge_username
|
|
22
|
+
unless @config
|
|
23
|
+
begin
|
|
24
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
|
25
|
+
rescue
|
|
26
|
+
puts <<-EOS
|
|
27
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
|
28
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
|
29
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
|
30
|
+
EOS
|
|
31
|
+
exit
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
REV = nil
|
|
39
|
+
# UNCOMMENT IF REQUIRED:
|
|
40
|
+
# REV = YAML.load(`svn info`)['Revision']
|
|
41
|
+
VERS = Apriori::VERSION::STRING + (REV ? ".#{REV}" : "")
|
|
42
|
+
RDOC_OPTS = ['--quiet', '--title', 'apriori documentation',
|
|
43
|
+
"--opname", "index.html",
|
|
44
|
+
"--line-numbers",
|
|
45
|
+
# "--exclude=ext",
|
|
46
|
+
"--main", "README",
|
|
47
|
+
"--inline-source"]
|
|
48
|
+
|
|
49
|
+
class Hoe
|
|
50
|
+
def extra_deps
|
|
51
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
|
52
|
+
@extra_deps
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Generate all the Rake tasks
|
|
57
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
|
58
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
59
|
+
p.developer(AUTHOR, EMAIL)
|
|
60
|
+
p.description = DESCRIPTION
|
|
61
|
+
p.summary = DESCRIPTION
|
|
62
|
+
p.url = HOMEPATH
|
|
63
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
|
64
|
+
p.test_globs = ["test/**/test_*.rb"]
|
|
65
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
|
66
|
+
p.rdoc_pattern = /^(lib|bin)|txt$/
|
|
67
|
+
|
|
68
|
+
# p.spec_extras = {:extensions, FileList["ext/**/extconf.rb"].to_a} # A hash of extra values to set in the gemspec.
|
|
69
|
+
p.spec_extras = {:extensions, 'Rakefile'} # A hash of extra values to set in the gemspec.
|
|
70
|
+
|
|
71
|
+
# == Optional
|
|
72
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
|
73
|
+
p.extra_deps = EXTRA_DEPENDENCIES
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
|
78
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
|
79
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
|
80
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
|
81
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
include FileUtils
|
|
3
|
+
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
|
|
6
|
+
def check_rubygems_version
|
|
7
|
+
min_version = '1.2.0'
|
|
8
|
+
local_version = %x[gem --version].chomp
|
|
9
|
+
|
|
10
|
+
unless local_version >= min_version
|
|
11
|
+
puts "You need to update the RubyGems utility to #{min_version} using the following"
|
|
12
|
+
puts ""
|
|
13
|
+
puts " sudo gem update --system"
|
|
14
|
+
exit
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
check_rubygems_version
|
|
18
|
+
|
|
19
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
|
20
|
+
begin
|
|
21
|
+
require req_gem
|
|
22
|
+
rescue LoadError
|
|
23
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
|
24
|
+
puts "Installation: gem install #{req_gem} -y"
|
|
25
|
+
exit
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + "/../lib")
|
|
2
|
+
require 'apriori'
|
|
3
|
+
|
|
4
|
+
transactions = [ %w{beer doritos},
|
|
5
|
+
%w{apple cheese},
|
|
6
|
+
%w{beer doritos},
|
|
7
|
+
%w{apple cheese},
|
|
8
|
+
%w{apple cheese},
|
|
9
|
+
%w{apple doritos} ]
|
|
10
|
+
|
|
11
|
+
rules = Apriori.find_association_rules(transactions,
|
|
12
|
+
:min_items => 2,
|
|
13
|
+
:max_items => 5,
|
|
14
|
+
:min_support => 1,
|
|
15
|
+
:max_support => 100,
|
|
16
|
+
:min_confidence => 20)
|
|
17
|
+
|
|
18
|
+
puts rules.join("\n")
|
|
19
|
+
|
|
20
|
+
# RETURNS:
|
|
21
|
+
# doritos <- beer (33.3/2, 100.0)
|
|
22
|
+
# beer <- doritos (50.0/3, 66.7)
|
|
23
|
+
# apple <- doritos (50.0/3, 33.3)
|
|
24
|
+
# doritos <- apple (66.7/4, 25.0)
|
|
25
|
+
# apple <- cheese (50.0/3, 100.0)
|
|
26
|
+
# cheese <- apple (66.7/4, 75.0)
|
|
27
|
+
|
|
28
|
+
# NOTE:
|
|
29
|
+
# doritos <- beer (33.3/2, 100.0)
|
|
30
|
+
# means:
|
|
31
|
+
# * beer appears in 33.3% (2 total) of the transactions (the support)
|
|
32
|
+
# * beer implies doritos 100% of the time (the confidence)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + "/../lib")
|
|
2
|
+
require 'apriori'
|
|
3
|
+
require 'benchmark'
|
|
4
|
+
|
|
5
|
+
rules = nil
|
|
6
|
+
results = Benchmark.measure {
|
|
7
|
+
rules = Apriori.find_association_rules(File.dirname(__FILE__) + "/test_data/market_basket_basic_test.dat",
|
|
8
|
+
:min_items => 2,
|
|
9
|
+
:max_items => 3,
|
|
10
|
+
:min_support => 0.01,
|
|
11
|
+
:min_confidence => 30)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
puts rules.join("\n")
|
|
15
|
+
puts "#{rules.size} rules generated"
|
|
16
|
+
puts "Benchmarks:"
|
|
17
|
+
puts results
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + "/../lib")
|
|
2
|
+
require 'apriori'
|
|
3
|
+
require 'benchmark'
|
|
4
|
+
|
|
5
|
+
# NOTE: the 'accidents.dat' file is not supplied with this gem. To download it,
|
|
6
|
+
# run: rake apriori:get_example_data
|
|
7
|
+
# or see http://fimi.cs.helsinki.fi/data/
|
|
8
|
+
|
|
9
|
+
puts "This will take a little while. Hold tight..."
|
|
10
|
+
|
|
11
|
+
rules = nil
|
|
12
|
+
results = Benchmark.measure {
|
|
13
|
+
rules = Apriori.find_association_rules(File.dirname(__FILE__) + "/test_data/accidents.dat",
|
|
14
|
+
:min_items => 2,
|
|
15
|
+
:max_items => 10,
|
|
16
|
+
:min_support => 50,
|
|
17
|
+
:min_confidence => 80)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
puts "#{rules.size} rules generated"
|
|
21
|
+
puts "Benchmarks:"
|
|
22
|
+
puts results
|
data/ext/Apriori.c
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// Include the Ruby headers and goodies
|
|
2
|
+
#include "ruby.h"
|
|
3
|
+
#include "intern.h"
|
|
4
|
+
#include "apriori_wrapper.h"
|
|
5
|
+
|
|
6
|
+
// Defining a space for information and references about the module to be stored internally
|
|
7
|
+
VALUE Apriori = Qnil;
|
|
8
|
+
|
|
9
|
+
// Prototype for the initialization method - Ruby calls this, not you
|
|
10
|
+
void Init_mytest();
|
|
11
|
+
|
|
12
|
+
// Prototype for our method 'test1' - methods are prefixed by 'method_' here
|
|
13
|
+
VALUE method_do_test_apriori(VALUE self);
|
|
14
|
+
//VALUE method_test_hash_ap(VALUE self, VALUE filein, VALUE fileout, VALUE opts);
|
|
15
|
+
//VALUE method_find_association_rules(VALUE self, VALUE filein, VALUE fileout, VALUE opts);
|
|
16
|
+
|
|
17
|
+
VALUE method_ap_do_apriori(VALUE self, VALUE rargv);
|
|
18
|
+
|
|
19
|
+
// The initialization method for this module
|
|
20
|
+
void Init_apriori_ext() {
|
|
21
|
+
Apriori = rb_define_module("Apriori");
|
|
22
|
+
rb_define_method(Apriori, "do_test_apriori", method_do_test_apriori, 0);
|
|
23
|
+
rb_define_method(Apriori, "do_apriori", method_ap_do_apriori, 1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
VALUE method_do_test_apriori(VALUE self) {
|
|
27
|
+
char *arg0 = "apriori";
|
|
28
|
+
char *arg1 = "test/sample.txt";
|
|
29
|
+
char *arg2 = "test/results.txt";
|
|
30
|
+
char *argv[3];
|
|
31
|
+
argv[0] = arg0;
|
|
32
|
+
argv[1] = arg1;
|
|
33
|
+
argv[2] = arg2;
|
|
34
|
+
|
|
35
|
+
do_apriori(3, argv);
|
|
36
|
+
int x = 10;
|
|
37
|
+
return INT2NUM(x);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Our 'test1' method.. it simply returns a value of '10' for now.
|
|
41
|
+
/*
|
|
42
|
+
VALUE method_test_hash_ap(VALUE self, VALUE filein, VALUE fileout, VALUE opts) {
|
|
43
|
+
//VALUE s = rb_str_new2("hello");
|
|
44
|
+
VALUE s = rb_str_new2("bye");
|
|
45
|
+
VALUE val = rb_hash_aref(opts, rb_str_intern(s));
|
|
46
|
+
|
|
47
|
+
if(val != Qnil) {
|
|
48
|
+
return val;
|
|
49
|
+
} else {
|
|
50
|
+
return rb_str_new2("nope");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
// Our 'test1' method.. it simply returns a value of '10' for now.
|
|
56
|
+
/*
|
|
57
|
+
VALUE method_find_association_rules(VALUE self, VALUE filein, VALUE fileout, VALUE opts) {
|
|
58
|
+
VALUE s = rb_str_new2("hello");
|
|
59
|
+
//VALUE s = rb_str_new2("bye");
|
|
60
|
+
VALUE val = rb_hash_aref(opts, rb_str_intern(s));
|
|
61
|
+
|
|
62
|
+
if(val != Qnil) {
|
|
63
|
+
return val;
|
|
64
|
+
} else {
|
|
65
|
+
return rb_str_new2("nope");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
VALUE method_ap_do_apriori(VALUE self, VALUE rargv) {
|
|
71
|
+
char **argv; // todo, learn the best practice here
|
|
72
|
+
int i = 0;
|
|
73
|
+
VALUE ary_value;
|
|
74
|
+
// get the number of arguments
|
|
75
|
+
int ruby_argv_length = RARRAY(rargv)->len;
|
|
76
|
+
// allocate enough memory for a pointer to each char *
|
|
77
|
+
argv = malloc(ruby_argv_length * sizeof(*argv));
|
|
78
|
+
|
|
79
|
+
// copy the ruby array of strings to a c "array of strings"
|
|
80
|
+
// todo, turn this into a function
|
|
81
|
+
while((ary_value = rb_ary_shift(rargv)) != Qnil) {
|
|
82
|
+
argv[i] = malloc(strlen(STR2CSTR(ary_value)) + 1);
|
|
83
|
+
strcpy(argv[i], STR2CSTR(ary_value));
|
|
84
|
+
i++;
|
|
85
|
+
}
|
|
86
|
+
do_apriori(i, argv);
|
|
87
|
+
return Qnil;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
VALUE better_method_ap_test_ruby_array(VALUE self, VALUE rargv) {
|
|
92
|
+
char **argv;
|
|
93
|
+
int i = 3;
|
|
94
|
+
argv = (char **)convert_rb_ary_strings_to_c_ary_strings(rargv);
|
|
95
|
+
do_apriori(i, argv);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
char **convert_rb_ary_strings_to_c_ary_strings(VALUE rary) {
|
|
99
|
+
char **argv; // todo, learn the best practice here
|
|
100
|
+
int i = 0;
|
|
101
|
+
VALUE ary_value;
|
|
102
|
+
// get the number of arguments
|
|
103
|
+
int ruby_argv_length = RARRAY(rary)->len;
|
|
104
|
+
// allocate enough memory for a pointer to each char *
|
|
105
|
+
argv = malloc(ruby_argv_length * sizeof(*argv));
|
|
106
|
+
|
|
107
|
+
// copy the ruby array of strings to a c "array of strings"
|
|
108
|
+
// todo, turn this into a function
|
|
109
|
+
while((ary_value = rb_ary_shift(rary)) != Qnil) {
|
|
110
|
+
argv[i] = malloc(strlen(STR2CSTR(ary_value)) + 1);
|
|
111
|
+
strcpy(argv[i], STR2CSTR(ary_value));
|
|
112
|
+
fprintf(stderr, "%s\n", argv[i]);
|
|
113
|
+
i++;
|
|
114
|
+
}
|
|
115
|
+
printf("%d\n", i);
|
|
116
|
+
return argv;
|
|
117
|
+
}
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
void asdf_junk_box() {
|
|
121
|
+
/* int j; */
|
|
122
|
+
/* for(j=0; j<i; j++) { */
|
|
123
|
+
/* fprintf(stderr, "%s\n", argv[j]); */
|
|
124
|
+
/* } */
|
|
125
|
+
|
|
126
|
+
// VALUE tmp_argv = rb_ary_new();
|
|
127
|
+
//do_apriori(i, argv);
|
|
128
|
+
|
|
129
|
+
// ok, so you need to figure out how many non-nil values you have,
|
|
130
|
+
// i guess you could just track it above.
|
|
131
|
+
// then we're good! we can feed these to the main
|
|
132
|
+
|
|
133
|
+
// for(i=0; i < NUM2INT(rb_ary_length(rargv)); i++) {
|
|
134
|
+
// VALUE argv = rb_ary_new();
|
|
135
|
+
//fprintf(stderr, STR2CSTR(rb_ary_fetch(1, 1, rargv)));
|
|
136
|
+
// }
|
|
137
|
+
// get an array of ruby strings
|
|
138
|
+
// convert it to a c array of char *'s
|
|
139
|
+
//
|
|
140
|
+
//VALUE s = rb_str_new2("bye");
|
|
141
|
+
//VALUE val = rb_hash_aref(opts, rb_str_intern(s));
|
|
142
|
+
|
|
143
|
+
/* if(val != Qnil) { */
|
|
144
|
+
/* return val; */
|
|
145
|
+
/* } else { */
|
|
146
|
+
/* return rb_str_new2("nope"); */
|
|
147
|
+
/* } */
|
|
148
|
+
return;
|
|
149
|
+
}
|
data/ext/Makefile
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
|
|
2
|
+
SHELL = /bin/sh
|
|
3
|
+
|
|
4
|
+
#### Start of system configuration section. ####
|
|
5
|
+
|
|
6
|
+
srcdir = /home/nathan/tmp/apriori/ext
|
|
7
|
+
topdir = /usr/local/lib/ruby/1.8/i686-linux
|
|
8
|
+
hdrdir = $(topdir)
|
|
9
|
+
VPATH = $(srcdir):$(topdir):$(hdrdir)
|
|
10
|
+
prefix = $(DESTDIR)/usr/local
|
|
11
|
+
exec_prefix = $(prefix)
|
|
12
|
+
sitedir = $(prefix)/lib/ruby/site_ruby
|
|
13
|
+
rubylibdir = $(libdir)/ruby/$(ruby_version)
|
|
14
|
+
docdir = $(datarootdir)/doc/$(PACKAGE)
|
|
15
|
+
dvidir = $(docdir)
|
|
16
|
+
datarootdir = $(prefix)/share
|
|
17
|
+
archdir = $(rubylibdir)/$(arch)
|
|
18
|
+
sbindir = $(exec_prefix)/sbin
|
|
19
|
+
psdir = $(docdir)
|
|
20
|
+
localedir = $(datarootdir)/locale
|
|
21
|
+
htmldir = $(docdir)
|
|
22
|
+
datadir = $(datarootdir)
|
|
23
|
+
includedir = $(prefix)/include
|
|
24
|
+
infodir = $(datarootdir)/info
|
|
25
|
+
sysconfdir = $(prefix)/etc
|
|
26
|
+
mandir = $(datarootdir)/man
|
|
27
|
+
libdir = $(exec_prefix)/lib
|
|
28
|
+
sharedstatedir = $(prefix)/com
|
|
29
|
+
oldincludedir = $(DESTDIR)/usr/include
|
|
30
|
+
pdfdir = $(docdir)
|
|
31
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
|
32
|
+
bindir = $(exec_prefix)/bin
|
|
33
|
+
localstatedir = $(prefix)/var
|
|
34
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
|
35
|
+
libexecdir = $(exec_prefix)/libexec
|
|
36
|
+
|
|
37
|
+
CC = gcc
|
|
38
|
+
LIBRUBY = $(LIBRUBY_A)
|
|
39
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
|
40
|
+
LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -L.
|
|
41
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
|
42
|
+
|
|
43
|
+
RUBY_EXTCONF_H =
|
|
44
|
+
CFLAGS = -fPIC -g -O2
|
|
45
|
+
INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
|
|
46
|
+
CPPFLAGS = -I/home/nathan/tmp/apriori/ext/util/src -I/home/nathan/tmp/apriori/ext/math/src -I/home/nathan/tmp/apriori/ext/apriori/src
|
|
47
|
+
CXXFLAGS = $(CFLAGS)
|
|
48
|
+
DLDFLAGS =
|
|
49
|
+
LDSHARED = $(CC) -shared
|
|
50
|
+
AR = ar
|
|
51
|
+
EXEEXT =
|
|
52
|
+
|
|
53
|
+
RUBY_INSTALL_NAME = ruby
|
|
54
|
+
RUBY_SO_NAME = ruby
|
|
55
|
+
arch = i686-linux
|
|
56
|
+
sitearch = i686-linux
|
|
57
|
+
ruby_version = 1.8
|
|
58
|
+
ruby = /usr/local/bin/ruby
|
|
59
|
+
RUBY = $(ruby)
|
|
60
|
+
RM = rm -f
|
|
61
|
+
MAKEDIRS = mkdir -p
|
|
62
|
+
INSTALL = /usr/bin/ginstall -c
|
|
63
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
|
64
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
|
65
|
+
COPY = cp
|
|
66
|
+
|
|
67
|
+
#### End of system configuration section. ####
|
|
68
|
+
|
|
69
|
+
preload =
|
|
70
|
+
|
|
71
|
+
libpath = $(libdir)
|
|
72
|
+
LIBPATH = -L'$(libdir)' -Wl,-R'$(libdir)'
|
|
73
|
+
DEFFILE =
|
|
74
|
+
|
|
75
|
+
CLEANFILES =
|
|
76
|
+
DISTCLEANFILES =
|
|
77
|
+
|
|
78
|
+
extout =
|
|
79
|
+
extout_prefix =
|
|
80
|
+
target_prefix =
|
|
81
|
+
LOCAL_LIBS =
|
|
82
|
+
LIBS = -ldl -lcrypt -lm -lc
|
|
83
|
+
SRCS = vecops.c nimap.c tabscan.c scform.c gamma.c chi2.c tract.c istree.c apriori_wrapper.c Apriori.c
|
|
84
|
+
OBJS = /home/nathan/tmp/apriori/ext/util/src/vecops.o /home/nathan/tmp/apriori/ext/util/src/nimap.o /home/nathan/tmp/apriori/ext/util/src/tabscan.o /home/nathan/tmp/apriori/ext/util/src/scform.o /home/nathan/tmp/apriori/ext/math/src/gamma.o /home/nathan/tmp/apriori/ext/math/src/chi2.o /home/nathan/tmp/apriori/ext/apriori/src/tract.o /home/nathan/tmp/apriori/ext/apriori/src/istree.o apriori_wrapper.o Apriori.o
|
|
85
|
+
TARGET = apriori_ext
|
|
86
|
+
DLLIB = $(TARGET).so
|
|
87
|
+
EXTSTATIC =
|
|
88
|
+
STATIC_LIB =
|
|
89
|
+
|
|
90
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
|
91
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
|
92
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
|
93
|
+
|
|
94
|
+
TARGET_SO = $(DLLIB)
|
|
95
|
+
CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
|
|
96
|
+
CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
|
|
97
|
+
|
|
98
|
+
all: $(DLLIB)
|
|
99
|
+
static: $(STATIC_LIB)
|
|
100
|
+
|
|
101
|
+
clean:
|
|
102
|
+
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
|
103
|
+
|
|
104
|
+
distclean: clean
|
|
105
|
+
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
|
106
|
+
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
|
107
|
+
|
|
108
|
+
realclean: distclean
|
|
109
|
+
install: install-so install-rb
|
|
110
|
+
|
|
111
|
+
install-so: $(RUBYARCHDIR)
|
|
112
|
+
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
|
113
|
+
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
|
114
|
+
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
|
115
|
+
install-rb: pre-install-rb install-rb-default
|
|
116
|
+
install-rb-default: pre-install-rb-default
|
|
117
|
+
pre-install-rb: Makefile
|
|
118
|
+
pre-install-rb-default: Makefile
|
|
119
|
+
$(RUBYARCHDIR):
|
|
120
|
+
$(MAKEDIRS) $@
|
|
121
|
+
|
|
122
|
+
site-install: site-install-so site-install-rb
|
|
123
|
+
site-install-so: install-so
|
|
124
|
+
site-install-rb: install-rb
|
|
125
|
+
|
|
126
|
+
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
|
127
|
+
|
|
128
|
+
.cc.o:
|
|
129
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
|
130
|
+
|
|
131
|
+
.cxx.o:
|
|
132
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
|
133
|
+
|
|
134
|
+
.cpp.o:
|
|
135
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
|
136
|
+
|
|
137
|
+
.C.o:
|
|
138
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
|
139
|
+
|
|
140
|
+
.c.o:
|
|
141
|
+
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
|
|
142
|
+
|
|
143
|
+
$(DLLIB): $(OBJS)
|
|
144
|
+
@-$(RM) $@
|
|
145
|
+
$(LDSHARED) $(DLDFLAGS) $(LIBPATH) -o $@ $(OBJS) $(LOCAL_LIBS) $(LIBS)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
$(OBJS): ruby.h defines.h
|