wapiti 0.0.3 → 0.0.4
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/README.md +12 -4
- data/lib/wapiti/model.rb +15 -10
- data/lib/wapiti/options.rb +6 -2
- data/lib/wapiti/version.rb +1 -1
- metadata +10 -10
data/README.md
CHANGED
@@ -10,8 +10,15 @@ Thomas Lavergne's awesome [wapiti](http://wapiti.limsi.fr/).
|
|
10
10
|
Requirements
|
11
11
|
------------
|
12
12
|
|
13
|
-
Wapiti
|
14
|
-
support (e.g., gcc);
|
13
|
+
Wapiti is written in C and Ruby and requires a compiler with C99
|
14
|
+
support (e.g., gcc); on GNU/Linux systems it will be fairly easy to install
|
15
|
+
all necessary packages through your distribution; on Mac OS X you can either
|
16
|
+
install Xcode or
|
17
|
+
(osx-gcc-installer)[https://github.com/kennethreitz/osx-gcc-installer];
|
18
|
+
on Windows you may want to install RubyInstaller's
|
19
|
+
[DevKit](https://github.com/oneclick/rubyinstaller/wiki/development-kit).
|
20
|
+
|
21
|
+
The Wapiti Ruby gem has been confirmed to work with MRI 1.9, 1.8.7,
|
15
22
|
and Rubinius.
|
16
23
|
|
17
24
|
|
@@ -70,6 +77,7 @@ Before saving your model you can use `compact` to reduce the model's size:
|
|
70
77
|
model.save 'm2.mod'
|
71
78
|
=> # m2.mod file size 471K
|
72
79
|
|
80
|
+
|
73
81
|
### Loading existing Models
|
74
82
|
|
75
83
|
model = Wapiti::Model.load('m1.mod')
|
@@ -135,8 +143,8 @@ input, you can access the statistics via `#statistics` (the individual values
|
|
135
143
|
are also available through the associated attribute readers).
|
136
144
|
|
137
145
|
model.label 'test.txt', :check => true
|
138
|
-
=> {:tokens=>{:total=>1896, :errors=>137, :rate=>
|
139
|
-
:sequences=>{:total=>77, :errors=>50, :rate=>
|
146
|
+
=> {:tokens=>{:total=>1896, :errors=>137, :rate=>7.225738396624472},
|
147
|
+
:sequences=>{:total=>77, :errors=>50, :rate=>64.93506493506494}}
|
140
148
|
|
141
149
|
|
142
150
|
|
data/lib/wapiti/model.rb
CHANGED
@@ -41,21 +41,29 @@ module Wapiti
|
|
41
41
|
end
|
42
42
|
|
43
43
|
alias native_label label
|
44
|
-
|
44
|
+
|
45
45
|
def label(input, opts = nil)
|
46
46
|
options.update(opts) unless opts.nil?
|
47
47
|
block_given? ? native_label(input, &Proc.new) : native_label(input)
|
48
48
|
end
|
49
49
|
|
50
|
+
alias native_train train
|
51
|
+
|
52
|
+
def train(input, opts = nil)
|
53
|
+
options.update(opts) unless opts.nil?
|
54
|
+
block_given? ? native_train(input, &Proc.new) : native_train(input)
|
55
|
+
end
|
56
|
+
|
57
|
+
|
50
58
|
def statistics
|
51
59
|
s = {}
|
52
60
|
s[:tokens] = {
|
53
61
|
:total => token_count, :errors => @token_errors,
|
54
|
-
:rate => token_errors /
|
62
|
+
:rate => token_errors.to_f / token_count.to_f * 100.0
|
55
63
|
}
|
56
64
|
s[:sequences] = {
|
57
65
|
:total => sequence_count, :errors => sequence_errors,
|
58
|
-
:rate => sequence_errors /
|
66
|
+
:rate => sequence_errors.to_f / sequence_count.to_f * 100.0
|
59
67
|
}
|
60
68
|
s
|
61
69
|
end
|
@@ -67,13 +75,10 @@ module Wapiti
|
|
67
75
|
end
|
68
76
|
|
69
77
|
alias clear clear_counters
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
def tokenize(input)
|
75
|
-
input
|
76
|
-
end
|
78
|
+
|
79
|
+
# alias native_save save
|
80
|
+
|
81
|
+
private :native_label, :native_train
|
77
82
|
|
78
83
|
end
|
79
84
|
|
data/lib/wapiti/options.rb
CHANGED
@@ -11,7 +11,7 @@ module Wapiti
|
|
11
11
|
@attribute_names ||= %w{ stop_window convergence_window posterior
|
12
12
|
max_iterations jobsize threads rho1 rho2 stop_epsilon score check
|
13
13
|
algorithm pattern development_data maxent compact sparse skip_tokens
|
14
|
-
}.sort.map(&:to_sym).freeze
|
14
|
+
compress }.sort.map(&:to_sym).freeze
|
15
15
|
end
|
16
16
|
|
17
17
|
# Returns the default options.
|
@@ -26,6 +26,10 @@ module Wapiti
|
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
|
+
attr_accessor :compress
|
30
|
+
|
31
|
+
alias compress? compress
|
32
|
+
|
29
33
|
# Returns the value of the attribute identified by +name+ or nil
|
30
34
|
# if there is no such attribute.
|
31
35
|
def [](name)
|
@@ -104,7 +108,7 @@ module Wapiti
|
|
104
108
|
e
|
105
109
|
end
|
106
110
|
|
107
|
-
%w{ maxent compact sparse label check score posterior }.each do |m|
|
111
|
+
%w{ maxent compact sparse label check score posterior compress }.each do |m|
|
108
112
|
writer = "#{m}=".to_sym
|
109
113
|
define_method("#{m}!") do
|
110
114
|
send(writer, true)
|
data/lib/wapiti/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wapiti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-03 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156718440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.9'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156718440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake-compiler
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156717640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0.7'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156717640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: ZenTest
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156717060 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '4.6'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2156717060
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &2156685780 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '2.6'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2156685780
|
58
58
|
description: This gem provides a Ruby API for Conditional Random Fields (CRF). It
|
59
59
|
is implemented as a C exstension and based on the wicked fast "wapiti" package.
|
60
60
|
email:
|