wapiti 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.simplecov +3 -0
- data/Gemfile +25 -2
- data/HISTORY.md +5 -1
- data/LICENSE +14 -13
- data/README.md +9 -16
- data/Rakefile +38 -8
- data/ext/wapiti/bcd.c +126 -124
- data/ext/wapiti/decoder.c +203 -124
- data/ext/wapiti/decoder.h +6 -4
- data/ext/wapiti/extconf.rb +2 -2
- data/ext/wapiti/gradient.c +491 -320
- data/ext/wapiti/gradient.h +52 -34
- data/ext/wapiti/lbfgs.c +74 -33
- data/ext/wapiti/model.c +47 -37
- data/ext/wapiti/model.h +22 -20
- data/ext/wapiti/native.c +850 -839
- data/ext/wapiti/native.h +1 -1
- data/ext/wapiti/options.c +52 -20
- data/ext/wapiti/options.h +37 -30
- data/ext/wapiti/pattern.c +35 -33
- data/ext/wapiti/pattern.h +12 -11
- data/ext/wapiti/progress.c +14 -13
- data/ext/wapiti/progress.h +3 -2
- data/ext/wapiti/quark.c +14 -16
- data/ext/wapiti/quark.h +6 -5
- data/ext/wapiti/reader.c +83 -69
- data/ext/wapiti/reader.h +11 -9
- data/ext/wapiti/rprop.c +84 -43
- data/ext/wapiti/sequence.h +18 -16
- data/ext/wapiti/sgdl1.c +45 -43
- data/ext/wapiti/thread.c +19 -17
- data/ext/wapiti/thread.h +5 -4
- data/ext/wapiti/tools.c +7 -7
- data/ext/wapiti/tools.h +3 -4
- data/ext/wapiti/trainers.h +1 -1
- data/ext/wapiti/vmath.c +40 -38
- data/ext/wapiti/vmath.h +12 -11
- data/ext/wapiti/wapiti.c +159 -37
- data/ext/wapiti/wapiti.h +18 -4
- data/lib/wapiti.rb +15 -15
- data/lib/wapiti/errors.rb +15 -15
- data/lib/wapiti/model.rb +92 -84
- data/lib/wapiti/options.rb +123 -124
- data/lib/wapiti/utility.rb +14 -14
- data/lib/wapiti/version.rb +2 -2
- data/spec/spec_helper.rb +29 -9
- data/spec/wapiti/model_spec.rb +230 -194
- data/spec/wapiti/native_spec.rb +7 -8
- data/spec/wapiti/options_spec.rb +184 -174
- data/wapiti.gemspec +22 -8
- metadata +38 -42
- data/.gitignore +0 -5
data/spec/wapiti/native_spec.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
module Wapiti
|
2
2
|
describe 'Native Extension Module' do
|
3
|
-
|
3
|
+
|
4
4
|
it 'should define the wapiti version string' do
|
5
|
-
Native::VERSION.should match
|
5
|
+
Native::VERSION.should match(/^[\d\.]+$/)
|
6
6
|
end
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
7
|
+
|
8
|
+
it { Native.should respond_to(:label) }
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
data/spec/wapiti/options_spec.rb
CHANGED
@@ -1,175 +1,185 @@
|
|
1
1
|
module Wapiti
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
2
|
+
describe 'Options' do
|
3
|
+
|
4
|
+
let(:options) { Options.new }
|
5
|
+
|
6
|
+
it { Options.should be_an_instance_of(Class) }
|
7
|
+
|
8
|
+
it { options.should_not be nil }
|
9
|
+
|
10
|
+
describe '.defaults' do
|
11
|
+
it 'returns a hash with the default options' do
|
12
|
+
Options.defaults.keys.map(&:to_s).sort.should == Options.attribute_names.map(&:to_s)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#initialize' do
|
17
|
+
|
18
|
+
it 'should fail if called with more than one parameter' do
|
19
|
+
expect { Options.new(1,2) }.to raise_error
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should fail if called with a parameter that is no hash' do
|
23
|
+
expect { Options.new([]) }.to raise_error
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should set defaults according to the supplied hash' do
|
27
|
+
Options.new(:compact => true).should be_compact
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should accept and execute a self-yielding block' do
|
31
|
+
opt = Options.new(:compact => true) { |o| o.sparse = true }
|
32
|
+
opt.should be_compact
|
33
|
+
opt.should be_sparse
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'array accessors' do
|
39
|
+
it 'are supported' do
|
40
|
+
lambda { options[:threads] = 2 }.should change { options[:threads] }.from(1).to(2)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'fail for unknown attribute names' do
|
44
|
+
lambda { options[:unknown] = 2 }.should raise_error(ArgumentError)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#update' do
|
49
|
+
it 'sets all option values according to the given hash' do
|
50
|
+
lambda { options.update( :threads => 2 ) }.should change { options.threads }.from(1).to(2)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#threads' do
|
55
|
+
it 'returns 1 by default' do
|
56
|
+
options.threads.should == 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#threads=' do
|
61
|
+
it 'sets threads to the given value' do
|
62
|
+
lambda { options.threads = 2 }.should change { options.threads }.from(1).to(2)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#jobsize' do
|
67
|
+
it 'returns 64 by default' do
|
68
|
+
options.jobsize.should == 64
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#jobsize=' do
|
73
|
+
it 'sets jobsize to the given value' do
|
74
|
+
lambda { options.jobsize = 128 }.should change { options.jobsize }.by(64)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#maxiter' do
|
79
|
+
it 'returns a large number by default' do
|
80
|
+
options.maxiter.should > 0
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#maxiter=' do
|
85
|
+
it 'sets maxiter to the given value' do
|
86
|
+
lambda { options.maxiter = 20 }.should change { options.maxiter }.to(20)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#stop_window' do
|
91
|
+
it 'returns 5 by default' do
|
92
|
+
options.stop_window.should == 5
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#stop_window=' do
|
97
|
+
it 'sets stop_window to the given value' do
|
98
|
+
lambda { options.stop_window = 20 }.should change { options.stop_window }.by(15)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#convergence_window' do
|
103
|
+
it 'returns 5 by default' do
|
104
|
+
options.convergence_window.should == 5
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#convergence_window=' do
|
109
|
+
it 'sets convergence_window to the given value' do
|
110
|
+
lambda { options.convergence_window = 20 }.should change { options.convergence_window }.by(15)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
describe '#stop_epsilon' do
|
116
|
+
it 'returns 0.02 by default' do
|
117
|
+
options.stop_epsilon.should == 0.02
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe '#stop_epsilon=' do
|
122
|
+
it 'sets stop_epsilon to the given value' do
|
123
|
+
lambda { options.stop_epsilon = 0.35 }.should change { options.stop_epsilon }
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '#rho1' do
|
128
|
+
it 'returns 0.5 by default' do
|
129
|
+
options.rho1.should == 0.5
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#rho1=' do
|
134
|
+
it 'sets rho1 to the given value' do
|
135
|
+
lambda { options.rho1 = 2.5 }.should change { options.rho1 }.by(2)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#rho2' do
|
140
|
+
it 'returns 0.0001 by default' do
|
141
|
+
options.rho2.should == 0.0001
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe '#rho2=' do
|
146
|
+
it 'sets rho2 to the given value' do
|
147
|
+
lambda { options.rho2 = 0.0002 }.should change { options.rho2 }.by(0.0001)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
%w{ maxent compact sparse skip_tokens check score posterior }.each do |m|
|
153
|
+
describe "##{m}" do
|
154
|
+
it 'returns false by default' do
|
155
|
+
options.send(m).should be false
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "##{m}=" do
|
160
|
+
it "sets #{m} to the given value" do
|
161
|
+
lambda { options.send("#{m}=", true) }.should change { options.send(m) }.from(false).to(true)
|
162
|
+
lambda { options.send("#{m}=", false) }.should change { options.send(m) }.from(true).to(false)
|
163
|
+
lambda { options.send("#{m}=", 123) }.should change { options.send(m) }.from(false).to(true)
|
164
|
+
lambda { options.send("#{m}=", nil) }.should change { options.send(m) }.from(true).to(false)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
%w{ pattern model algorithm devel }.each do |m|
|
170
|
+
describe "##{m}" do
|
171
|
+
it 'returns an empty string by default' do
|
172
|
+
options.send(m).should be_a(String)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "##{m}=" do
|
177
|
+
it 'sets the input string to the given value' do
|
178
|
+
lambda { options.send("#{m}=", 'foo') }.should change { options.send(m) }.to('foo')
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
data/wapiti.gemspec
CHANGED
@@ -8,28 +8,42 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.name = 'wapiti'
|
9
9
|
s.version = Wapiti::VERSION.dup
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
|
+
|
11
12
|
s.authors = ['Sylvester Keil']
|
12
13
|
s.email = ['http://sylvester.keil.or.at']
|
14
|
+
|
13
15
|
s.homepage = 'https://github.com/inukshuk/wapiti-ruby'
|
14
16
|
s.summary = 'Wicked fast Conditional Random Fields for Ruby.'
|
15
|
-
s.description =
|
17
|
+
s.description =
|
18
|
+
"""
|
19
|
+
This gem provides a Ruby API for Conditional Random Fields (CRF).
|
20
|
+
"""
|
21
|
+
|
16
22
|
s.license = 'FreeBSD'
|
23
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
17
24
|
|
18
|
-
s.add_development_dependency('rake', '~>0
|
25
|
+
s.add_development_dependency('rake', '~>10.0')
|
19
26
|
s.add_development_dependency('rake-compiler', '~>0.7')
|
20
|
-
s.add_development_dependency('
|
21
|
-
|
27
|
+
s.add_development_dependency('rspec', '~>2.6')
|
28
|
+
|
29
|
+
s.files = `git ls-files`.split("\n") - %w{
|
30
|
+
vendor/wapiti
|
31
|
+
.coveralls.yml
|
32
|
+
.travis.yml
|
33
|
+
.gitmodules
|
34
|
+
.gitignore
|
35
|
+
}
|
22
36
|
|
23
|
-
s.files = `git ls-files`.split("\n")
|
24
37
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
38
|
+
|
25
39
|
s.executables = []
|
26
40
|
s.require_path = 'lib'
|
27
|
-
|
41
|
+
|
28
42
|
s.extensions << 'ext/wapiti/extconf.rb'
|
29
43
|
|
30
44
|
s.rdoc_options = %w{--line-numbers --inline-source --title "Wapiti-Ruby" --main README.md --webcvs=http://github.com/inukshuk/wapiti-ruby/tree/master/}
|
31
45
|
s.extra_rdoc_files = %w{README.md LICENSE}
|
32
|
-
|
46
|
+
|
33
47
|
end
|
34
48
|
|
35
|
-
# vim: syntax=ruby
|
49
|
+
# vim: syntax=ruby
|
metadata
CHANGED
@@ -1,62 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wapiti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sylvester Keil
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0
|
19
|
+
version: '10.0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rake-compiler
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- - ~>
|
31
|
+
- - "~>"
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0.7'
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: ZenTest
|
38
|
-
requirement: &2156553240 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- - ~>
|
38
|
+
- - "~>"
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
44
|
-
type: :development
|
45
|
-
prerelease: false
|
46
|
-
version_requirements: *2156553240
|
40
|
+
version: '0.7'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: rspec
|
49
|
-
requirement:
|
50
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
51
44
|
requirements:
|
52
|
-
- - ~>
|
45
|
+
- - "~>"
|
53
46
|
- !ruby/object:Gem::Version
|
54
47
|
version: '2.6'
|
55
48
|
type: :development
|
56
49
|
prerelease: false
|
57
|
-
version_requirements:
|
58
|
-
|
59
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.6'
|
55
|
+
description: "\n This gem provides a Ruby API for Conditional Random Fields (CRF).\n
|
56
|
+
\ "
|
60
57
|
email:
|
61
58
|
- http://sylvester.keil.or.at
|
62
59
|
executables: []
|
@@ -66,9 +63,9 @@ extra_rdoc_files:
|
|
66
63
|
- README.md
|
67
64
|
- LICENSE
|
68
65
|
files:
|
69
|
-
- .autotest
|
70
|
-
- .
|
71
|
-
- .
|
66
|
+
- ".autotest"
|
67
|
+
- ".rspec"
|
68
|
+
- ".simplecov"
|
72
69
|
- Gemfile
|
73
70
|
- HISTORY.md
|
74
71
|
- LICENSE
|
@@ -132,34 +129,33 @@ files:
|
|
132
129
|
homepage: https://github.com/inukshuk/wapiti-ruby
|
133
130
|
licenses:
|
134
131
|
- FreeBSD
|
132
|
+
metadata: {}
|
135
133
|
post_install_message:
|
136
134
|
rdoc_options:
|
137
|
-
- --line-numbers
|
138
|
-
- --inline-source
|
139
|
-
- --title
|
140
|
-
-
|
141
|
-
- --main
|
135
|
+
- "--line-numbers"
|
136
|
+
- "--inline-source"
|
137
|
+
- "--title"
|
138
|
+
- "\"Wapiti-Ruby\""
|
139
|
+
- "--main"
|
142
140
|
- README.md
|
143
|
-
- --webcvs=http://github.com/inukshuk/wapiti-ruby/tree/master/
|
141
|
+
- "--webcvs=http://github.com/inukshuk/wapiti-ruby/tree/master/"
|
144
142
|
require_paths:
|
145
143
|
- lib
|
146
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
-
none: false
|
148
145
|
requirements:
|
149
|
-
- -
|
146
|
+
- - ">="
|
150
147
|
- !ruby/object:Gem::Version
|
151
148
|
version: '0'
|
152
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
150
|
requirements:
|
155
|
-
- -
|
151
|
+
- - ">="
|
156
152
|
- !ruby/object:Gem::Version
|
157
153
|
version: '0'
|
158
154
|
requirements: []
|
159
155
|
rubyforge_project:
|
160
|
-
rubygems_version:
|
156
|
+
rubygems_version: 2.2.2
|
161
157
|
signing_key:
|
162
|
-
specification_version:
|
158
|
+
specification_version: 4
|
163
159
|
summary: Wicked fast Conditional Random Fields for Ruby.
|
164
160
|
test_files:
|
165
161
|
- spec/fixtures/ch.mod
|