classify3 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/classify3/bayes.rb +48 -0
- data/lib/classify3/version.rb +3 -0
- data/lib/classify3.rb +5 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d55110ddda42057d504e71d30118f2fe074cf37d73dc67a932a8b8e3d88cbbc4
|
4
|
+
data.tar.gz: 1a9afc4f66f22b0fbd503072fcf1a9ad1c820ba67f7e899378829dcd0d76e392
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f45eae56265b94dcec6659b7e936860d6218725195d3438a8227a235dd93632876acb511efb27ace2eb60a4cc10d287de9e0f259c0a4f3b0ab9da7156defe109
|
7
|
+
data.tar.gz: 99f53b684a491f9a47de501b6a5c91d1f7abf0acab2c9714629532d2b4729bc2b72296c7a2ba37875dc5ba610665018e0338aa0c4189f8f9d58001d1b8b282c7
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Classify3
|
2
|
+
class Bayes
|
3
|
+
def initialize
|
4
|
+
@rust = Classify3::Rust::Binding.new
|
5
|
+
end
|
6
|
+
|
7
|
+
def add(doc, label)
|
8
|
+
@rust.add(doc, label)
|
9
|
+
end
|
10
|
+
|
11
|
+
def train
|
12
|
+
@rust.train
|
13
|
+
end
|
14
|
+
|
15
|
+
def classify(str)
|
16
|
+
@rust.classify(str)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Rust < FFI::AutoPointer
|
21
|
+
def self.release(ptr)
|
22
|
+
Binding.free(ptr)
|
23
|
+
end
|
24
|
+
|
25
|
+
def add(doc, label)
|
26
|
+
Binding.add(self, doc, label)
|
27
|
+
end
|
28
|
+
|
29
|
+
def train
|
30
|
+
Binding.train(self)
|
31
|
+
end
|
32
|
+
|
33
|
+
def classify(str)
|
34
|
+
Binding.classify(self, str)
|
35
|
+
end
|
36
|
+
|
37
|
+
module Binding
|
38
|
+
extend FFI::Library
|
39
|
+
ffi_lib './ffi/libclassify3.so'
|
40
|
+
|
41
|
+
attach_function :new, :bayes_new, [], Rust
|
42
|
+
attach_function :free, :bayes_free, [Rust], :void
|
43
|
+
attach_function :add, :bayes_add, [Rust, :string, :string], :void
|
44
|
+
attach_function :train, :bayes_train, [Rust], :void
|
45
|
+
attach_function :classify, :bayes_classify, [Rust, :string], :string
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/classify3.rb
ADDED
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: classify3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Olivia Hugger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
description: Fast Bayes Classifier
|
28
|
+
email: olivia@fastmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/classify3.rb
|
34
|
+
- lib/classify3/bayes.rb
|
35
|
+
- lib/classify3/version.rb
|
36
|
+
homepage: https://github.com/oe/classify3
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.7.6
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Fast Bayes Classifier
|
60
|
+
test_files: []
|