thomas 0.1.1 → 0.1.2
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/lib/thomas.rb +5 -6
- metadata +2 -2
data/lib/thomas.rb
CHANGED
@@ -21,22 +21,21 @@ module Adocca
|
|
21
21
|
|
22
22
|
class Update
|
23
23
|
def initialize(model, corpus, word, amount)
|
24
|
-
@
|
24
|
+
@model_name = model.name
|
25
25
|
@corpus = corpus
|
26
26
|
@word = word
|
27
27
|
@amount = amount
|
28
28
|
end
|
29
29
|
def execute
|
30
|
-
|
31
|
-
instance =
|
30
|
+
model = Module.const_get(@model_name)
|
31
|
+
instance = model.find_by_corpus_and_word(@corpus, @word)
|
32
|
+
instance = model.create(:corpus => @corpus, :word => @word) unless instance
|
32
33
|
instance.update_attribute(:amount, (instance.amount || 0) + @amount)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
37
|
class Bayes
|
37
38
|
|
38
|
-
NAMESPACE = 'adocca:thomas:bayes'
|
39
|
-
|
40
39
|
attr_accessor :model
|
41
40
|
|
42
41
|
@@updates = []
|
@@ -106,7 +105,7 @@ module Adocca
|
|
106
105
|
protected
|
107
106
|
|
108
107
|
def flush_updates
|
109
|
-
if @@updates.size >
|
108
|
+
if @@updates.size > 200 || (defined?($FLUSH_THOMAS) && $FLUSH_THOMAS)
|
110
109
|
@model.transaction do
|
111
110
|
until @@updates.empty?
|
112
111
|
@@updates.pop.execute
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: thomas
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2006-11-
|
6
|
+
version: 0.1.2
|
7
|
+
date: 2006-11-23 00:00:00 +01:00
|
8
8
|
summary: Bayes classifier using memcached
|
9
9
|
require_paths:
|
10
10
|
- lib
|