neuro 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,6 @@
1
+ 2009-08-27 (0.4.1)
2
+ * Started using rake-compiler.
3
+ * Some reorganisation of the repository contents, documentation etc.
4
+ * Create a gemspec file.
5
+ 2005-10-02 (0.4.0)
6
+ * Initial Released Version
data/Rakefile CHANGED
@@ -1,42 +1,44 @@
1
- require 'rake/clean'
2
- require 'rake/testtask'
3
- require 'rake/gempackagetask'
1
+ begin
2
+ require 'rake/gempackagetask'
3
+ require 'rake/extensiontask'
4
+ rescue LoadError
5
+ end
6
+
4
7
  require 'rbconfig'
5
8
  include Config
6
- require 'find'
7
- include Find
8
9
 
10
+ require 'rake/clean'
11
+ CLEAN.include 'doc', 'coverage', FileList["**/*.dump"],
12
+ FileList["ext/*.{o,so,#{CONFIG['DLEXT']}}"], 'lib/*.so',
13
+ 'ext/Makefile'
14
+
15
+ MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
9
16
  PKG_NAME = 'neuro'
10
17
  PKG_VERSION = File.read('VERSION').chomp
11
- PKG_FILES = FileList['**/*']
12
- PKG_FILES.exclude('CVS')
13
- PKG_FILES.exclude('pkg')
14
- PKG_FILES.exclude(/\.dump$/)
18
+ PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|doc|tmp|coverage|(\.dump\Z)/).to_a
15
19
 
16
- task :default => [:test]
20
+ task :default => :test
17
21
 
18
22
  desc "Run unit tests"
19
- task(:test => [:compile]) do
20
- cd 'tests' do
21
- ruby %{-I../ext runner.rb}
22
- end
23
+ task :test => :compile_ext do
24
+ sh 'testrb -Iext:lib tests/test_*.rb'
23
25
  end
24
26
 
25
27
  desc "Creating documentation"
26
28
  task :doc do
27
- sh 'rdoc -m Neuro -d -o doc ext/neuro.c'# lib/neuro/display.rb'
29
+ sh 'rdoc -t "neuro - Neural Network Extension for Ruby" -m doc-main.txt -o doc doc-main.txt ext/neuro.c lib/neuro/version.rb' # lib/neuro/display.rb'
28
30
  end
29
31
 
30
32
  desc "Compiling library"
31
- task :compile do
33
+ task :compile_ext do
32
34
  cd 'ext' do
33
35
  ruby 'extconf.rb'
34
- sh 'make'
36
+ sh MAKE
35
37
  end
36
38
  end
37
39
 
38
40
  desc "Installing library"
39
- task(:install => [:test]) do
41
+ task :install => :test do
40
42
  src = "ext/neuro.#{CONFIG['DLEXT']}"
41
43
  filename = File.basename(src)
42
44
  dst = File.join(CONFIG["sitelibdir"], filename)
@@ -49,68 +51,81 @@ task(:install => [:test]) do
49
51
  install(src, dst, :verbose => true, :mode => 0644)
50
52
  end
51
53
 
52
- task :clean do
53
- find('.') do |f|
54
- if f =~ /\.dump$/
55
- rm f
56
- end
57
- end
58
- cd 'ext' do
59
- sh 'make distclean' rescue nil
60
- end
61
- end
62
-
63
- spec = Gem::Specification.new do |s|
64
-
65
- #### Basic information.
66
-
67
- s.name = 'neuro'
68
- s.version = PKG_VERSION
69
- s.summary = "Neural Network Extension for Ruby"
70
- s.description = <<EOF
54
+ if defined?(Gem) and defined?(Rake::GemPackageTask) and
55
+ defined?(Rake::ExtensionTask)
56
+ then
57
+ spec_src = <<-GEM
58
+ Gem::Specification.new do |s|
59
+ s.name = '#{PKG_NAME}'
60
+ s.version = '#{PKG_VERSION}'
61
+ s.summary = "Neural Network Extension for Ruby"
62
+ s.description = <<EOF
71
63
  A Ruby extension that provides a 2-Layer Back Propagation Neural Network, which
72
64
  can be used to categorize datasets of arbitrary size.
73
65
  EOF
74
66
 
75
- #### Dependencies and requirements.
67
+ s.files = #{PKG_FILES.to_a.sort.inspect}
76
68
 
77
- #s.add_dependency('log4r', '> 1.0.4')
78
- #s.requirements << ""
69
+ s.extensions = "ext/extconf.rb"
79
70
 
80
- s.files = PKG_FILES
71
+ s.require_paths << 'ext' << 'lib'
81
72
 
82
- #### C code extensions.
73
+ s.has_rdoc = true
74
+ s.extra_rdoc_files << 'doc-main.txt'
75
+ s.rdoc_options << '--main' << 'doc-main.txt' << '--title' << 'Neural Network Extension for Ruby'
76
+ s.test_files.concat #{Dir['tests/test_*.rb'].to_a.sort.inspect}
83
77
 
84
- s.extensions << "ext/extconf.rb"
85
-
86
- #### Load-time details: library and application (you will need one or both).
87
-
88
- s.require_path = 'ext' # Use these for libraries.
89
- s.autorequire = 'neuro'
90
-
91
- #s.bindir = "bin" # Use these for applications.
92
- #s.executables = ["foo.rb"]
93
- #s.default_executable = "foo.rb"
94
-
95
- #### Documentation and testing.
78
+ s.author = "Florian Frank"
79
+ s.email = "flori@ping.de"
80
+ s.homepage = "http://neuro.rubyforge.org"
81
+ s.rubyforge_project = '#{PKG_NAME}'
82
+ end
83
+ GEM
96
84
 
97
- s.has_rdoc = true
98
- s.extra_rdoc_files = [ 'ext/neuro.c' ]
99
- s.rdoc_options << '--main' << 'Neuro'
100
- s.test_files << 'tests/runner.rb'
85
+ desc 'Create a gemspec file'
86
+ task :gemspec do
87
+ File.open("#{PKG_NAME}.gemspec", 'w') do |f|
88
+ f.puts spec_src
89
+ end
90
+ end
101
91
 
102
- #### Author and project details.
92
+ spec = eval(spec_src)
93
+ Rake::GemPackageTask.new(spec) do |pkg|
94
+ pkg.need_tar = true
95
+ pkg.package_files = PKG_FILES
96
+ end
103
97
 
104
- s.author = "Florian Frank"
105
- s.email = "flori@ping.de"
106
- s.homepage = "http://neuro.rubyforge.org"
107
- s.rubyforge_project = "neuro"
98
+ Rake::ExtensionTask.new do |ext|
99
+ ext.name = PKG_NAME
100
+ ext.gem_spec = spec
101
+ ext.cross_compile = true
102
+ ext.cross_platform = 'i386-mswin32'
103
+ ext.ext_dir = 'ext'
104
+ ext.lib_dir = 'lib'
105
+ end
108
106
  end
109
107
 
110
- Rake::GemPackageTask.new(spec) do |pkg|
111
- pkg.package_files += PKG_FILES
112
- pkg.need_tar = true
108
+ desc m = "Writing version information for #{PKG_VERSION}"
109
+ task :version do
110
+ puts m
111
+ File.open(File.join('lib', 'neuro', 'version.rb'), 'w') do |v|
112
+ v.puts <<EOT
113
+ module Neuro
114
+ # Neuro version
115
+ VERSION = '#{PKG_VERSION}'
116
+ VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
117
+ VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
118
+ VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
119
+ VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
120
+ end
121
+ EOT
122
+ end
113
123
  end
114
124
 
115
- task :release => [ :clean, :compile, :package ]
116
- # vim: set et sw=2 ts=2:
125
+ task :default => [ :version, :gemspec, :test ]
126
+
127
+ desc "Build all gems and archives for a new release."
128
+ task :release => [ :clean, :version, :gemspec, :cross, :native, :gem ] do
129
+ system "#$0 clean native gem"
130
+ system "#$0 clean package"
131
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
data/doc-main.txt ADDED
@@ -0,0 +1,33 @@
1
+ == Description
2
+
3
+ A Ruby extension that provides a 2-Layer Back Propagation Neural Network,
4
+ which can be used to categorize datasets of arbitrary size.
5
+
6
+ The network can be easily stored to or restored from the hard disk with
7
+ the help of Ruby's Marshal facility.
8
+
9
+ == Author
10
+
11
+ Florian Frank <mailto:flori@ping.de>
12
+
13
+ == License
14
+
15
+ This is free software; you can redistribute it and/or modify it under
16
+ the terms of the GNU General Public License Version 2 as published by
17
+ the Free Software Foundation: http://www.gnu.org/copyleft/gpl.html
18
+
19
+ == Download
20
+
21
+ The latest version of <b>neuro</b> can be found at
22
+
23
+ * http://rubyforge.org/frs/?group_id=554
24
+
25
+ The homepage should be located at
26
+
27
+ * http://neuro.rubyforge.org
28
+
29
+ == Examples
30
+
31
+ An example for optical character recognition can be found in the examples
32
+ subdirectory. Don't forget to check out the tests subdirectory, which
33
+ contains some additional examples.
data/examples/ocr.rb CHANGED
@@ -113,7 +113,8 @@ if $0 == __FILE__
113
113
  ocr = OCR.new
114
114
  loop do
115
115
  puts "", "Input a character from 'A'-'Z': "
116
- c = gets.chomp
116
+ c = gets or break
117
+ c.chomp!
117
118
  c.tr!('a-z', 'A-Z')
118
119
  break unless /^[A-Z]$/.match(c)
119
120
  input_char = OCR.noisify(c, 5)
@@ -122,4 +123,3 @@ if $0 == __FILE__
122
123
  puts "Understood '#{rec_char.char}':", rec_char
123
124
  end
124
125
  end
125
- # vim: set et sw=2 ts=2:
data/ext/neuro.c CHANGED
@@ -624,46 +624,9 @@ static VALUE rb_network_load(VALUE klass, VALUE string)
624
624
  return Data_Wrap_Struct(klass, NULL, rb_network_free, network);
625
625
  }
626
626
 
627
- /*
628
- *
629
- * = neuro - Neuronal Network Extension for Ruby
630
- *
631
- * == Description
632
- *
633
- * A Ruby extension that provides a 2-Layer Back Propagation Neural Network,
634
- * which can be used to categorize datasets of arbitrary size.
635
- *
636
- * The network can be easily stored to or restored from the hard disk with
637
- * the help of Ruby's Marshal facility.
638
- *
639
- * == Author
640
- *
641
- * Florian Frank <mailto:flori@ping.de>
642
- *
643
- * == License
644
- *
645
- * This is free software; you can redistribute it and/or modify it under
646
- * the terms of the GNU General Public License Version 2 as published by
647
- * the Free Software Foundation: http://www.gnu.org/copyleft/gpl.html
648
- *
649
- * == Download
650
- *
651
- * The latest version of <b>neuro</b> can be found at
652
- *
653
- * * http://rubyforge.org/frs/?group_id=554
654
- *
655
- * The homepage should be located at
656
- *
657
- * * http://neuro.rubyforge.org
658
- *
659
- * == Examples
660
- *
661
- * An example for optical character recognition can be found in the examples
662
- * subdirectory. Don't forget to check out the tests subdirectory, which
663
- * contains some additional examples.
664
- */
665
627
  void Init_neuro()
666
628
  {
629
+ rb_require("neuro/version");
667
630
  rb_mNeuro = rb_define_module("Neuro");
668
631
  rb_cNetwork = rb_define_class_under(rb_mNeuro, "Network", rb_cObject);
669
632
  rb_cNeuroError = rb_define_class("NetworkError", rb_eStandardError);
@@ -691,4 +654,3 @@ void Init_neuro()
691
654
  id_class = rb_intern("class");
692
655
  id_name = rb_intern("name");
693
656
  }
694
- /* vim: set cin sw=4 ts=4: */
data/install.rb CHANGED
@@ -5,18 +5,25 @@ include Config
5
5
  require 'fileutils'
6
6
  include FileUtils::Verbose
7
7
 
8
- cd 'ext' do
9
- system 'ruby extconf.rb'
10
- system 'make'
8
+ MAKE = if RUBY_PLATFORM =~ /mswin32/i
9
+ 'nmake'
10
+ else
11
+ ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
11
12
  end
12
13
 
13
- file = "ext/neuro.#{CONFIG['DLEXT']}"
14
- dst = CONFIG["sitelibdir"]
15
- install(file, dst)
14
+ bindir = CONFIG['bindir']
15
+ archdir = CONFIG['sitearchdir']
16
+ libdir = CONFIG['sitelibdir']
17
+ dlext = CONFIG['DLEXT']
16
18
 
17
- file = 'lib/neuro/display.rb'
18
- dst_dir = File.join(CONFIG["sitelibdir"], 'neuro')
19
- dst = File.join(dst_dir, File.basename(file))
20
- mkdir_p dst_dir
21
- install(file, dst)
22
- # vim: set et sw=2 ts=2:
19
+ cd 'ext' do
20
+ system 'ruby extconf.rb' or exit 1
21
+ system "#{MAKE}" or exit 1
22
+ mkdir_p archdir
23
+ install "neuro.#{dlext}", archdir
24
+ end
25
+
26
+ mkdir_p dst_dir = File.join(libdir, 'neuro')
27
+ for file in Dir['lib/neuro/*.rb']
28
+ install file, File.join(dst_dir, File.basename(file))
29
+ end
data/lib/neuro.so ADDED
Binary file
data/lib/neuro/display.rb CHANGED
@@ -430,4 +430,3 @@ if $0 == __FILE__
430
430
  ngui.start
431
431
  par.run
432
432
  end
433
- # vim: set et sw=2 ts=2:
@@ -0,0 +1,8 @@
1
+ module Neuro
2
+ # Neuro version
3
+ VERSION = '0.4.1'
4
+ VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
+ VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
+ VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
7
+ VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
8
+ end
data/neuro.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'neuro'
3
+ s.version = '0.4.1'
4
+ s.summary = "Neural Network Extension for Ruby"
5
+ s.description = <<EOF
6
+ A Ruby extension that provides a 2-Layer Back Propagation Neural Network, which
7
+ can be used to categorize datasets of arbitrary size.
8
+ EOF
9
+
10
+ s.files = ["CHANGES", "Rakefile", "VERSION", "examples", "examples/ocr.rb", "ext", "ext/extconf.rb", "ext/neuro.c", "install.rb", "lib", "lib/neuro", "lib/neuro/display.rb", "lib/neuro/version.rb", "neuro.gemspec", "tests", "tests/test_even_odd.rb", "tests/test_parity.rb"]
11
+
12
+ s.extensions = "ext/extconf.rb"
13
+
14
+ s.require_paths << 'ext' << 'lib'
15
+
16
+ s.has_rdoc = true
17
+ s.extra_rdoc_files << 'doc-main.txt'
18
+ s.rdoc_options << '--main' << 'doc-main.txt' << '--title' << 'Neural Network Extension for Ruby'
19
+ s.test_files.concat ["tests/test_even_odd.rb", "tests/test_parity.rb"]
20
+
21
+ s.author = "Florian Frank"
22
+ s.email = "flori@ping.de"
23
+ s.homepage = "http://neuro.rubyforge.org"
24
+ s.rubyforge_project = 'neuro'
25
+ end
@@ -1,11 +1,10 @@
1
- #!/usr/bin/env ruby
2
1
  #
3
2
  # Stupid little test, that finds out if 5-bit numbers are even or odd.
4
3
  #
5
4
  require 'test/unit'
6
5
  require 'neuro'
7
6
 
8
- class TC_EvenOdd < Test::Unit::TestCase
7
+ class TestEvenOdd < Test::Unit::TestCase
9
8
  include Neuro
10
9
 
11
10
  @@even = [
@@ -66,4 +65,3 @@ class TC_EvenOdd < Test::Unit::TestCase
66
65
  end
67
66
  end
68
67
  end
69
- # vim: set et sw=2 ts=2:
data/tests/test_parity.rb CHANGED
@@ -1,9 +1,7 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'test/unit'
4
2
  require 'neuro'
5
3
 
6
- class TC_Parity < Test::Unit::TestCase
4
+ class TestParity < Test::Unit::TestCase
7
5
  include Neuro
8
6
 
9
7
  MAX_BITS = 4
@@ -55,4 +53,3 @@ class TC_Parity < Test::Unit::TestCase
55
53
  end
56
54
  end
57
55
  end
58
- # vim: set et sw=2 ts=2:
metadata CHANGED
@@ -1,59 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
3
- specification_version: 1
4
2
  name: neuro
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.4.0
7
- date: 2005-10-03 00:00:00 +02:00
8
- summary: Neural Network Extension for Ruby
9
- require_paths:
10
- - ext
11
- email: flori@ping.de
12
- homepage: http://neuro.rubyforge.org
13
- rubyforge_project: neuro
14
- description: "A Ruby extension that provides a 2-Layer Back Propagation Neural Network, which
15
- can be used to categorize datasets of arbitrary size."
16
- autorequire: neuro
17
- default_executable:
4
+ version: 0.4.1
5
+ platform: ruby
6
+ authors:
7
+ - Florian Frank
8
+ autorequire:
18
9
  bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-31 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: |
17
+ A Ruby extension that provides a 2-Layer Back Propagation Neural Network, which
18
+ can be used to categorize datasets of arbitrary size.
19
+
20
+ email: flori@ping.de
21
+ executables: []
22
+
23
+ extensions:
24
+ - ext/extconf.rb
25
+ extra_rdoc_files:
26
+ - doc-main.txt
27
+ files:
28
+ - CHANGES
29
+ - Rakefile
30
+ - VERSION
31
+ - examples/ocr.rb
32
+ - ext/extconf.rb
33
+ - ext/neuro.c
34
+ - install.rb
35
+ - lib/neuro.so
36
+ - lib/neuro/display.rb
37
+ - lib/neuro/version.rb
38
+ - neuro.gemspec
39
+ - tests/test_even_odd.rb
40
+ - tests/test_parity.rb
41
+ - doc-main.txt
19
42
  has_rdoc: true
20
- required_ruby_version: !ruby/object:Gem::Version::Requirement
43
+ homepage: http://neuro.rubyforge.org
44
+ licenses: []
45
+
46
+ post_install_message:
47
+ rdoc_options:
48
+ - --main
49
+ - doc-main.txt
50
+ - --title
51
+ - Neural Network Extension for Ruby
52
+ require_paths:
53
+ - lib
54
+ - ext
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
21
57
  requirements:
22
- -
23
- - ">"
24
- - !ruby/object:Gem::Version
25
- version: 0.0.0
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
26
61
  version:
27
- platform: ruby
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project: neuro
71
+ rubygems_version: 1.3.4
28
72
  signing_key:
29
- cert_chain:
30
- authors:
31
- - Florian Frank
32
- files:
33
- - examples
34
- - Rakefile
35
- - VERSION
36
- - install.rb
37
- - ext
38
- - lib
39
- - tests
40
- - examples/ocr.rb
41
- - ext/extconf.rb
42
- - ext/neuro.c
43
- - lib/neuro
44
- - lib/neuro/display.rb
45
- - tests/runner.rb
46
- - tests/test_even_odd.rb
47
- - tests/test_parity.rb
73
+ specification_version: 3
74
+ summary: Neural Network Extension for Ruby
48
75
  test_files:
49
- - tests/runner.rb
50
- rdoc_options:
51
- - "--main"
52
- - Neuro
53
- extra_rdoc_files:
54
- - ext/neuro.c
55
- executables: []
56
- extensions:
57
- - ext/extconf.rb
58
- requirements: []
59
- dependencies: []
76
+ - tests/test_even_odd.rb
77
+ - tests/test_parity.rb
data/tests/runner.rb DELETED
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit/ui/console/testrunner'
4
- require 'test/unit/testsuite'
5
- $:.unshift File.expand_path(File.dirname($0))
6
- require 'test_parity'
7
- require 'test_even_odd'
8
-
9
- class TS_AllTests
10
- def self.suite
11
- suite = Test::Unit::TestSuite.new
12
- suite << TC_Parity.suite
13
- suite << TC_EvenOdd.suite
14
- suite
15
- end
16
- end
17
- Test::Unit::UI::Console::TestRunner.run(TS_AllTests)
18
- # vim: set et sw=2 ts=2: