neuro 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ .*.sw[pon]
2
+ Gemfile.lock
3
+ pkg
@@ -0,0 +1,7 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ruby-head
6
+ - ree
7
+ - rbx
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ 2011-12-01 (0.4.3)
2
+ * Fix remaining Ruby 1.9 bug in ocr.rb example that caused the example network
3
+ not to converge.
4
+ * Use gem_hadar library.
5
+ * Test on travis-ci now.
1
6
  2011-05-22 (0.4.2)
2
7
  * 1.9.2 compatibility
3
8
  2009-08-27 (0.4.1)
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # vim: set filetype=ruby et sw=2 ts=2:
2
+
3
+ source :rubygems
4
+
5
+ gemspec
@@ -1,3 +1,5 @@
1
+ = Neuro - Neural Network Extension for Ruby
2
+
1
3
  == Description
2
4
 
3
5
  A Ruby extension that provides a 2-Layer Back Propagation Neural Network,
@@ -18,13 +20,11 @@ the Free Software Foundation: http://www.gnu.org/copyleft/gpl.html
18
20
 
19
21
  == Download
20
22
 
21
- The latest version of <b>neuro</b> can be found at
22
-
23
- * http://rubyforge.org/frs/?group_id=554
23
+ The homepage should be located at http://flori.github.com/neuro
24
24
 
25
- The homepage should be located at
25
+ Typing this into the shell should install the newest version.
26
26
 
27
- * http://neuro.rubyforge.org
27
+ $ gem install neuro
28
28
 
29
29
  == Examples
30
30
 
data/Rakefile CHANGED
@@ -1,119 +1,37 @@
1
1
  # vim: set filetype=ruby et sw=2 ts=2:
2
2
 
3
- begin
4
- require 'rake/gempackagetask'
5
- rescue LoadError
6
- end
7
-
8
- require 'rbconfig'
9
- include Config
10
-
11
- require 'rake/clean'
12
- CLEAN.include 'doc', 'coverage', FileList["**/*.dump"],
13
- FileList["ext/*.{o,so,#{CONFIG['DLEXT']}}"], 'lib/*.so',
14
- 'ext/Makefile'
15
-
16
- MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
17
- PKG_NAME = 'neuro'
18
- PKG_VERSION = File.read('VERSION').chomp
19
- PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|doc|tmp|coverage|(\.dump\Z)/).to_a
20
-
21
- task :default => :test
22
-
23
- desc "Run unit tests"
24
- task :test => :compile_ext do
25
- sh 'testrb -Iext:lib ./tests/test_*.rb'
26
- end
27
-
28
- desc "Creating documentation"
29
- task :doc do
30
- 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'
31
- end
32
-
33
- desc "Compiling library"
34
- task :compile_ext do
35
- cd 'ext' do
36
- ruby 'extconf.rb'
37
- sh MAKE
38
- end
39
- end
40
-
41
- desc "Installing library"
42
- task :install => :test do
43
- src = "ext/neuro.#{CONFIG['DLEXT']}"
44
- filename = File.basename(src)
45
- dst = File.join(CONFIG["sitelibdir"], filename)
46
- install(src, dst, :verbose => true, :mode => 0644)
47
- src = 'lib/neuro/display.rb'
48
- filename = File.basename(src)
49
- dst_dir = File.join(CONFIG["sitelibdir"], 'neuro')
50
- mkdir_p dst_dir
51
- dst = File.join(dst_dir, filename)
52
- install(src, dst, :verbose => true, :mode => 0644)
53
- end
54
-
55
- if defined?(Gem) and defined?(Rake::GemPackageTask)
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
3
+ require 'gem_hadar'
4
+
5
+ GemHadar do
6
+ name 'neuro'
7
+ author 'Florian Frank'
8
+ email 'flori@ping.de'
9
+ homepage "http://flori.github.com/#{name}"
10
+ summary 'Neural Network Extension for Ruby'
11
+ description <<EOT
63
12
  A Ruby extension that provides a 2-Layer Back Propagation Neural Network, which
64
13
  can be used to categorize datasets of arbitrary size.
65
- EOF
66
-
67
- s.files = #{PKG_FILES.to_a.sort.inspect}
68
-
69
- s.extensions = "ext/extconf.rb"
70
-
71
- s.require_paths << 'ext' << 'lib'
72
-
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}
77
-
78
- s.author = "Florian Frank"
79
- s.email = "flori@ping.de"
80
- s.homepage = "http://flori.github.com/#{PKG_NAME}"
81
- s.rubyforge_project = '#{PKG_NAME}'
82
- end
83
- GEM
84
-
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
91
-
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
97
- end
98
-
99
- desc m = "Writing version information for #{PKG_VERSION}"
100
- task :version do
101
- puts m
102
- File.open(File.join('lib', 'neuro', 'version.rb'), 'w') do |v|
103
- v.puts <<EOT
104
- module Neuro
105
- # Neuro version
106
- VERSION = '#{PKG_VERSION}'
107
- VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
108
- VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
109
- VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
110
- VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
111
- end
112
14
  EOT
15
+ test_dir 'tests'
16
+ ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock'
17
+ clean '*.dump'
18
+ title "#{name.camelize} - #{summary}"
19
+ readme 'README.rdoc'
20
+ require_paths %w[lib ext]
21
+ development_dependency 'test-unit', '~>2.4'
22
+
23
+ install_library do
24
+ src = "ext/neuro.#{CONFIG['DLEXT']}"
25
+ filename = File.basename(src)
26
+ dst = File.join(CONFIG["sitelibdir"], filename)
27
+ install(src, dst, :verbose => true, :mode => 0644)
28
+ dst_dir = File.join(CONFIG["sitelibdir"], 'neuro')
29
+ mkdir_p dst_dir
30
+ cd 'lib/neuro' do
31
+ for src in Dir['*.rb']
32
+ dst = File.join(dst_dir, src)
33
+ install(src, dst, :verbose => true, :mode => 0644)
34
+ end
35
+ end
113
36
  end
114
37
  end
115
-
116
- task :default => [ :version, :gemspec, :test ]
117
-
118
- desc "Build all gems and archives for a new release."
119
- task :release => [ :clean, :version, :gemspec, :package]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.4.3
@@ -42,7 +42,7 @@ class OCR
42
42
  vector = []
43
43
  7.times do |j|
44
44
  c = CHAR_BTIMAP[j][6 * number, 5]
45
- vector += c.enum_for(:each_byte).map { |x| x == ?* ? 1.0 : -1.0 }
45
+ vector += c.split(//).map { |x| x == '*' ? 1.0 : -1.0 }
46
46
  end
47
47
  CHARACTERS << Character.new(char, number, vector)
48
48
  end
@@ -62,7 +62,7 @@ class OCR
62
62
  eta = 0.2
63
63
  max_count = CHARACTERS.size * 10
64
64
  count = max_count
65
- until count < max_error
65
+ until count < max_count
66
66
  count = 0
67
67
  CHARACTERS.sort_by { rand }.each do |character|
68
68
  count += @network.learn(character.vector,
@@ -1,6 +1,6 @@
1
1
  require 'mkmf'
2
2
 
3
- if CONFIG['CC'] == 'gcc'
3
+ if CONFIG['CC'] =~ /gcc/
4
4
  CONFIG['CC'] = 'gcc -Wall -O2'
5
5
  end
6
6
  create_makefile 'neuro'
@@ -1,6 +1,6 @@
1
1
  module Neuro
2
2
  # Neuro version
3
- VERSION = '0.4.2'
3
+ VERSION = '0.4.3'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -1,25 +1,36 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'neuro'
3
- s.version = '0.4.2'
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
1
+ # -*- encoding: utf-8 -*-
9
2
 
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"]
3
+ Gem::Specification.new do |s|
4
+ s.name = "neuro"
5
+ s.version = "0.4.3"
11
6
 
12
- s.extensions = "ext/extconf.rb"
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Florian Frank"]
9
+ s.date = "2011-12-01"
10
+ s.description = "A Ruby extension that provides a 2-Layer Back Propagation Neural Network, which\ncan be used to categorize datasets of arbitrary size.\n"
11
+ s.email = "flori@ping.de"
12
+ s.extensions = ["ext/extconf.rb"]
13
+ s.extra_rdoc_files = ["README.rdoc", "lib/neuro/version.rb", "lib/neuro/display.rb", "ext/neuro.c"]
14
+ s.files = [".gitignore", ".travis.yml", "CHANGES", "Gemfile", "README.rdoc", "Rakefile", "VERSION", "examples/ocr.rb", "ext/extconf.rb", "ext/neuro.c", "install.rb", "lib/neuro/display.rb", "lib/neuro/version.rb", "neuro.gemspec", "tests/test_even_odd.rb", "tests/test_parity.rb"]
15
+ s.homepage = "http://flori.github.com/neuro"
16
+ s.rdoc_options = ["--title", "Neuro - Neural Network Extension for Ruby", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib", "ext"]
18
+ s.rubygems_version = "1.8.11"
19
+ s.summary = "Neural Network Extension for Ruby"
20
+ s.test_files = ["tests/test_even_odd.rb", "tests/test_parity.rb"]
13
21
 
14
- s.require_paths << 'ext' << 'lib'
22
+ if s.respond_to? :specification_version then
23
+ s.specification_version = 3
15
24
 
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://flori.github.com/neuro"
24
- s.rubyforge_project = 'neuro'
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ s.add_development_dependency(%q<gem_hadar>, ["~> 0.1.3"])
27
+ s.add_development_dependency(%q<test-unit>, ["~> 2.4"])
28
+ else
29
+ s.add_dependency(%q<gem_hadar>, ["~> 0.1.3"])
30
+ s.add_dependency(%q<test-unit>, ["~> 2.4"])
25
31
  end
32
+ else
33
+ s.add_dependency(%q<gem_hadar>, ["~> 0.1.3"])
34
+ s.add_dependency(%q<test-unit>, ["~> 2.4"])
35
+ end
36
+ end
metadata CHANGED
@@ -1,36 +1,59 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: neuro
3
- version: !ruby/object:Gem::Version
4
- hash: 11
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 4
9
- - 2
10
- version: 0.4.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Florian Frank
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
12
+ date: 2011-12-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gem_hadar
16
+ requirement: &78750830 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.3
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *78750830
25
+ - !ruby/object:Gem::Dependency
26
+ name: test-unit
27
+ requirement: &78750110 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '2.4'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *78750110
36
+ description: ! 'A Ruby extension that provides a 2-Layer Back Propagation Neural Network,
37
+ which
17
38
 
18
- date: 2011-05-22 00:00:00 Z
19
- dependencies: []
20
-
21
- description: |
22
- A Ruby extension that provides a 2-Layer Back Propagation Neural Network, which
23
39
  can be used to categorize datasets of arbitrary size.
24
40
 
41
+ '
25
42
  email: flori@ping.de
26
43
  executables: []
27
-
28
- extensions:
44
+ extensions:
29
45
  - ext/extconf.rb
30
- extra_rdoc_files:
31
- - doc-main.txt
32
- files:
46
+ extra_rdoc_files:
47
+ - README.rdoc
48
+ - lib/neuro/version.rb
49
+ - lib/neuro/display.rb
50
+ - ext/neuro.c
51
+ files:
52
+ - .gitignore
53
+ - .travis.yml
33
54
  - CHANGES
55
+ - Gemfile
56
+ - README.rdoc
34
57
  - Rakefile
35
58
  - VERSION
36
59
  - examples/ocr.rb
@@ -42,45 +65,35 @@ files:
42
65
  - neuro.gemspec
43
66
  - tests/test_even_odd.rb
44
67
  - tests/test_parity.rb
45
- - doc-main.txt
46
68
  homepage: http://flori.github.com/neuro
47
69
  licenses: []
48
-
49
70
  post_install_message:
50
- rdoc_options:
51
- - --main
52
- - doc-main.txt
71
+ rdoc_options:
53
72
  - --title
54
- - Neural Network Extension for Ruby
55
- require_paths:
73
+ - Neuro - Neural Network Extension for Ruby
74
+ - --main
75
+ - README.rdoc
76
+ require_paths:
56
77
  - lib
57
78
  - ext
58
- - lib
59
- required_ruby_version: !ruby/object:Gem::Requirement
79
+ required_ruby_version: !ruby/object:Gem::Requirement
60
80
  none: false
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- hash: 3
65
- segments:
66
- - 0
67
- version: "0"
68
- required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
86
  none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 3
74
- segments:
75
- - 0
76
- version: "0"
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
77
91
  requirements: []
78
-
79
- rubyforge_project: neuro
80
- rubygems_version: 1.7.1
92
+ rubyforge_project:
93
+ rubygems_version: 1.8.11
81
94
  signing_key:
82
95
  specification_version: 3
83
96
  summary: Neural Network Extension for Ruby
84
- test_files:
97
+ test_files:
85
98
  - tests/test_even_odd.rb
86
99
  - tests/test_parity.rb