vowpalwabbit 0.3.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +1 -1
- data/lib/vowpalwabbit/model.rb +24 -13
- data/lib/vowpalwabbit/version.rb +1 -1
- metadata +4 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7b187c7b0c8d3fd4b5f4473c14e9f47fbd80375bc63ead8907b2a51b946cda0
|
|
4
|
+
data.tar.gz: dbd111a8baa38a41504c8945528b237334679cb8c277359e09ba5bfdb624fa62
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94a54904710fb651b0f9d1be9a41869439221568352e44faa1f5731685ff3ba00cd99c4e0066e6a6ffc2ab24ffe5423527471615d4c9502cbaa8e23652b23bed
|
|
7
|
+
data.tar.gz: e3a6f921f6815e601d13f05640caeb4fb9c589237213773acfc283fb6347dc8d1ba02e3f4d9b0c74e8d427b30d56ae160ec56d36e2994f0b4b68fd402b227abf
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
BSD 3-Clause License
|
|
2
2
|
|
|
3
3
|
Copyright (c) Microsoft Corp 2012-2014, Yahoo! Inc. 2007-2012, and many individual contributors
|
|
4
|
-
Copyright (c) 2019-
|
|
4
|
+
Copyright (c) 2019-2026, Andrew Kane
|
|
5
5
|
All rights reserved.
|
|
6
6
|
|
|
7
7
|
Redistribution and use in source and binary forms, with or without
|
data/lib/vowpalwabbit/model.rb
CHANGED
|
@@ -52,7 +52,7 @@ module VowpalWabbit
|
|
|
52
52
|
bin_str = File.binread(filename)
|
|
53
53
|
model_data = ::FFI::MemoryPointer.new(:char, bin_str.bytesize)
|
|
54
54
|
model_data.put_bytes(0, bin_str)
|
|
55
|
-
@handle = FFI.VW_InitializeWithModel(param_str(@params), model_data, bin_str.bytesize)
|
|
55
|
+
@handle = wrap_handle(FFI.VW_InitializeWithModel(param_str(@params), model_data, bin_str.bytesize))
|
|
56
56
|
nil
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -64,9 +64,12 @@ module VowpalWabbit
|
|
|
64
64
|
|
|
65
65
|
private
|
|
66
66
|
|
|
67
|
-
# TODO clean-up handle
|
|
68
67
|
def handle
|
|
69
|
-
@handle ||= FFI.VW_InitializeA(param_str(@params))
|
|
68
|
+
@handle ||= wrap_handle(FFI.VW_InitializeA(param_str(@params)))
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def wrap_handle(handle)
|
|
72
|
+
::FFI::AutoPointer.new(handle, FFI.method(:VW_Finish))
|
|
70
73
|
end
|
|
71
74
|
|
|
72
75
|
def param_str(params)
|
|
@@ -120,16 +123,21 @@ module VowpalWabbit
|
|
|
120
123
|
if x.is_a?(String)
|
|
121
124
|
raise ArgumentError, "Cannot pass y with file" if y
|
|
122
125
|
|
|
123
|
-
file_handle = FFI.VW_InitializeA(param_str(data: x, quiet: true))
|
|
126
|
+
file_handle = wrap_handle(FFI.VW_InitializeA(param_str(data: x, quiet: true)))
|
|
124
127
|
FFI.VW_StartParser(file_handle)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
begin
|
|
129
|
+
loop do
|
|
130
|
+
example = FFI.VW_GetExample(file_handle)
|
|
131
|
+
begin
|
|
132
|
+
break if example.read_pointer.null?
|
|
133
|
+
yield example
|
|
134
|
+
ensure
|
|
135
|
+
FFI.VW_FinishExample(file_handle, example)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
ensure
|
|
139
|
+
FFI.VW_EndParser(file_handle)
|
|
130
140
|
end
|
|
131
|
-
FFI.VW_EndParser(file_handle)
|
|
132
|
-
FFI.VW_Finish(file_handle)
|
|
133
141
|
else
|
|
134
142
|
x = x.to_a
|
|
135
143
|
if y
|
|
@@ -146,8 +154,11 @@ module VowpalWabbit
|
|
|
146
154
|
end
|
|
147
155
|
|
|
148
156
|
example = FFI.VW_ReadExampleA(handle, line)
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
begin
|
|
158
|
+
yield example
|
|
159
|
+
ensure
|
|
160
|
+
FFI.VW_FinishExample(handle, example)
|
|
161
|
+
end
|
|
151
162
|
end
|
|
152
163
|
end
|
|
153
164
|
end
|
data/lib/vowpalwabbit/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vowpalwabbit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kane
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: ffi
|
|
@@ -24,7 +23,6 @@ dependencies:
|
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '0'
|
|
27
|
-
description:
|
|
28
26
|
email: andrew@ankane.org
|
|
29
27
|
executables: []
|
|
30
28
|
extensions: []
|
|
@@ -43,7 +41,6 @@ homepage: https://github.com/ankane/vowpalwabbit-ruby
|
|
|
43
41
|
licenses:
|
|
44
42
|
- BSD-3-Clause
|
|
45
43
|
metadata: {}
|
|
46
|
-
post_install_message:
|
|
47
44
|
rdoc_options: []
|
|
48
45
|
require_paths:
|
|
49
46
|
- lib
|
|
@@ -51,15 +48,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
51
48
|
requirements:
|
|
52
49
|
- - ">="
|
|
53
50
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '3.
|
|
51
|
+
version: '3.3'
|
|
55
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
53
|
requirements:
|
|
57
54
|
- - ">="
|
|
58
55
|
- !ruby/object:Gem::Version
|
|
59
56
|
version: '0'
|
|
60
57
|
requirements: []
|
|
61
|
-
rubygems_version:
|
|
62
|
-
signing_key:
|
|
58
|
+
rubygems_version: 4.0.6
|
|
63
59
|
specification_version: 4
|
|
64
60
|
summary: Fast online machine learning for Ruby
|
|
65
61
|
test_files: []
|