plastictrophy-libsvm-ruby-swig 0.3.3

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/AUTHORS ADDED
@@ -0,0 +1,3 @@
1
+ Tom Zeng <tom.z.zeng@mail.com> (Ruby SWIG interface to LIBSVM)
2
+ FeedbackMine <feedbackmine@feedbackmine.com> (gem)
3
+ Chih-Chung Chang and Chih-Jen Lin <cjlin@csie.ntu.edu.tw> (developers of LIBSVM)
data/COPYING ADDED
@@ -0,0 +1,24 @@
1
+ == LICENSE:
2
+
3
+ (The MIT License)
4
+
5
+ Copyright (c) 2009 Tom Zeng
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ 'Software'), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/History.txt ADDED
@@ -0,0 +1,7 @@
1
+ 2009-03-04 Tom Zeng (tom.z.zeng@gmail.com)
2
+ * adopted the gem spec by feedbackmine.com
3
+ 2009-05-14 Tom Zeng
4
+ * upgrade LIBSVM to 2.89
5
+ 2009-09-08 Mariano Lizarraga
6
+ * modified to support OSX
7
+ * Changed to use newgem Hoe plugin
data/Manifest.txt ADDED
@@ -0,0 +1,12 @@
1
+ History.txt
2
+ COPYING
3
+ AUTHORS
4
+ Manifest.txt
5
+ README.rdoc
6
+ Rakefile
7
+ lib/svm.rb
8
+ ext/libsvm_wrap.cxx
9
+ ext/svm.cpp
10
+ ext/svm.h
11
+ ext/extconf.rb
12
+ ext/Makefile
data/README.rdoc ADDED
@@ -0,0 +1,60 @@
1
+ = libsvm-ruby-swig
2
+
3
+ * Ruby interface to LIBSVM (using SWIG)
4
+ * http://www.tomzconsulting.com
5
+ * http://tweetsentiments.com
6
+
7
+ == DESCRIPTION:
8
+
9
+ This is the Ruby port of the LIBSVM Python SWIG (Simplified Wrapper and
10
+ Interface Generator) interface.
11
+
12
+ A slightly modified version of LIBSVM 2.89 is included, it allows turrning on/off
13
+ the debug log. You don't need your own copy of SWIG to use this library - all
14
+ needed files are generated using SWIG already.
15
+
16
+ Look for the README file in the ruby subdirectory for instructions.
17
+ The binaries included were built under Ubuntu Linux 2.6.24-23-generic,
18
+ you should run make under the libsvm-2.89 and libsvm-2.89/ruby
19
+ directories to regenerate the executables for your environment.
20
+
21
+ LIBSVM is in use at http://tweetsentiments.com - A Twitter / Tweet sentiment
22
+ analysis application
23
+
24
+ == INSTALL:
25
+ Currently the gem is available on linux only(tested on Ubuntu 8 and Fedora 9/10,
26
+ and on OS X by danielsdeleo), and you will need g++ installed to compile the
27
+ native code.
28
+
29
+ sudo gem sources -a http://gems.github.com (you only have to do this once)
30
+ sudo gem install tomz-libsvm-ruby-swig
31
+
32
+ == SYNOPSIS:
33
+
34
+ Quick Interactive Tutorial using irb (adopted from the python code from Toby
35
+ Segaran's "Programming Collective Intelligence" book):
36
+
37
+ irb(main):001:0> require 'svm'
38
+ => true
39
+ irb(main):002:0> prob = Problem.new([1,-1],[[1,0,1],[-1,0,-1]])
40
+ irb(main):003:0> param = Parameter.new(:kernel_type => LINEAR, :C => 10)
41
+ irb(main):004:0> m = Model.new(prob,param)
42
+ irb(main):005:0> m.predict([1,1,1])
43
+ => 1.0
44
+ irb(main):006:0> m.predict([0,0,1])
45
+ => 1.0
46
+ irb(main):007:0> m.predict([0,0,-1])
47
+ => -1.0
48
+ irb(main):008:0> m.save("test.model")
49
+ irb(main):009:0> m2 = Model.new("test.model")
50
+ irb(main):010:0> m2.predict([0,0,-1])
51
+ => -1.0
52
+
53
+ == AUTHOR:
54
+
55
+ Tom Zeng
56
+ - http://twitter.com/tomzeng
57
+ - http://www.tomzconsulting.com
58
+ - http://www.linkedin.com/in/tomzeng
59
+ - tom.z.zeng _at_ gmail _dot_ com
60
+
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+
6
+ Hoe.plugin :newgem
7
+
8
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
9
+ $hoe = Hoe.spec 'libsvm-ruby-swig' do
10
+ self.developer 'Tom Zeng', 'tom.z.zeng@gmail.com'
11
+ # self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
12
+ self.rubyforge_name = nil # TODO this is default value
13
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
14
+ self.version = '0.3.3'
15
+ self.url = 'http://www.tomzconsulting.com'
16
+ self.description = 'Ruby wrapper of LIBSVM using SWIG'
17
+ self.spec_extras[:extensions] = "ext/extconf.rb"
18
+ end
19
+
20
+
21
+ task :default => ["sync_files","make_gem"]
22
+
23
+ task :make_gem do
24
+ Dir.chdir "ext" do
25
+ ruby "extconf.rb"
26
+ sh "make"
27
+ end
28
+ end
29
+
30
+ task :sync_files do
31
+ cp "libsvm-2.89/svm.h","ext/"
32
+ cp "libsvm-2.89/svm.cpp","ext/"
33
+ cp "libsvm-2.89/ruby/libsvm_wrap.cxx","ext/"
34
+ cp "libsvm-2.89/ruby/svm.rb","lib/"
35
+ end
36
+
37
+ task :test do
38
+ puts "done"
39
+ end
data/ext/Makefile ADDED
@@ -0,0 +1,30 @@
1
+ CXX? = g++
2
+ SWIG ?= swig
3
+
4
+ #Windows: see ../README ../Makefile.win
5
+ RUBY_INCLUDEDIR ?= /usr/lib/ruby/1.8/universal-darwin9.0/
6
+
7
+ CFLAGS = -O3 -I$(RUBY_INCLUDEDIR) -I.. -arch i386
8
+ #LDFLAGS = -shared
9
+ # Mac OS
10
+ LDFLAGS = -framework Ruby -bundle
11
+
12
+ all: libsvm.bundle
13
+
14
+ libsvm.bundle: libsvm_wrap.o svm.o
15
+ $(CXX) $(LDFLAGS) -o libsvm.bundle libsvm_wrap.o svm.o
16
+
17
+ libsvm_wrap.o: svm.h
18
+ $(CXX) $(CFLAGS) -fPIC -c libsvm_wrap.cxx
19
+
20
+ svm.o: svm.cpp svm.h
21
+ $(CXX) $(CFLAGS) -fPIC -c svm.cpp
22
+
23
+ clean:
24
+ rm -f *~ *.o *.bundle svm.o
25
+
26
+ moreclean: clean
27
+ rm -f libsvm_wrap.c??
28
+
29
+ install:
30
+ cp libsvm.bundle ../lib/
data/ext/extconf.rb ADDED
@@ -0,0 +1,10 @@
1
+ # require 'mkmf'
2
+ #
3
+ # CONFIG["CC"] = "g++"
4
+ # $CFLAGS = "#{ENV['CFLAGS']} -Wall -O3 -arch i386 -arch ppc"
5
+ # if CONFIG["MAJOR"].to_i >= 1 && CONFIG["MINOR"].to_i >= 8
6
+ # $CFLAGS << " -DHAVE_DEFINE_ALLOC_FUNCTION"
7
+ # end
8
+ # create_makefile('libsvm')
9
+ #
10
+ # `make`