huginn_naive_bayes_agent 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/huginn_naive_bayes_agent/naive_bayes_agent.rb +3 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d1a1c1469bb599fe8a5a42a94e89fd6206e519d
|
4
|
+
data.tar.gz: d2ce17b2c8471199add13b73c92047cb84881c4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb4ae84beb82c52900b99d21c9ca3d542f9e99f1bee34794ef1bb92e6191559d89f4afa6c8a7f5cbf5918e1967df8dadd0c89c90bd9d8f7ffd32382017a4018e
|
7
|
+
data.tar.gz: a4c1e57328ddc1fef840f73aeeeb5072fc251b2d5fe03e649c175e43b46515775f0fa74336d3bbd1964280ee83276e6a8a0d431a786b7c59998c1ec188cdcc07
|
@@ -14,7 +14,7 @@ module Agents
|
|
14
14
|
* `nb_content` for the content used for classification, space separated.
|
15
15
|
* `nb_cats` for the classification categories, space separated.
|
16
16
|
|
17
|
-
If `nb_cats` is empty
|
17
|
+
If `nb_cats` is empty or contains `=class`, then the content from `nb_content` will be classified according to the training data. The categories will be added to `nb_cats` and then a new event is created with that payload.
|
18
18
|
|
19
19
|
However, if `nb_cats` is already populated, then the content from `nb_content` will be used as training data for the categories listed in `nb_cats`. For instance, say `nb_cats` consists of `trees`. Then `nb_content` will be used as training data for the category `trees`. The data is saved to the agent memory.
|
20
20
|
|
@@ -59,7 +59,7 @@ module Agents
|
|
59
59
|
def receive(incoming_events)
|
60
60
|
incoming_events.each do |event|
|
61
61
|
nbayes = load(memory['data'])
|
62
|
-
if event.payload['nb_cats'].length
|
62
|
+
if event.payload['nb_cats'].length > 0 and not event.payload['nb_cats'].include?("=class")
|
63
63
|
cats = event.payload['nb_cats'].split(/\s+/)
|
64
64
|
if cats[0] == "=loadYML"
|
65
65
|
memory['data'] = event.payload['nb_content']
|
@@ -84,7 +84,7 @@ module Agents
|
|
84
84
|
else
|
85
85
|
result = nbayes.classify(event.payload['nb_content'].split(/\s+/))
|
86
86
|
if interpolated['min_value'].to_f == 1
|
87
|
-
result.max_class
|
87
|
+
event.payload['nb_cats'] << (event.payload['nb_cats'].length == 0 ? result.max_class : " "+result.max_class)
|
88
88
|
else
|
89
89
|
result.each do |cat, val|
|
90
90
|
if val > interpolated['min_value'].to_f
|
@@ -113,24 +113,5 @@ module Agents
|
|
113
113
|
nbayes
|
114
114
|
end
|
115
115
|
|
116
|
-
# def purge_less_than(x)
|
117
|
-
# remove_list = {}
|
118
|
-
# nbayes = load(memory['data'])
|
119
|
-
# nbayes.vocab.each do |token|
|
120
|
-
# if nbayes.data.purge_less_than(token, x)
|
121
|
-
# # print "removing #{token}\n"
|
122
|
-
# remove_list[token] = 1
|
123
|
-
# end
|
124
|
-
# end # each vocab word
|
125
|
-
# remove_list.keys.each {|token| nbayes.vocab.delete(token) }
|
126
|
-
# memory['data'] = YAML.dump(nbayes)
|
127
|
-
# end
|
128
|
-
|
129
|
-
# Delete an entire category from the classification data
|
130
|
-
# def delete_category(category)
|
131
|
-
# nbayes = load(memory['data'])
|
132
|
-
# nbayes.data.delete_category(category)
|
133
|
-
# memory['data'] = YAML.dump(nbayes)
|
134
|
-
# end
|
135
116
|
end
|
136
117
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huginn_naive_bayes_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Greenstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04
|
11
|
+
date: 2017-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|