@@ -80,13 +80,13 @@ def train(category, text)
80
80
end
81
81
end
82
82
83
- @backend . update_category_training_count ( category , 1 )
84
- @backend . update_total_trainings ( 1 )
85
83
word_hash . each do |word , count |
86
84
@backend . update_category_word_frequency ( category , word , count )
87
85
@backend . update_category_word_count ( category , count )
88
86
@backend . update_total_words ( count )
89
87
end
88
+ @backend . update_total_trainings ( 1 )
89
+ @backend . update_category_training_count ( category , 1 )
90
90
end
91
91
92
92
# Provides a untraining method for all categories specified in Bayes#new
@@ -100,8 +100,6 @@ def untrain(category, text)
100
100
word_hash = Hasher . word_hash ( text , @language , @enable_stemmer )
101
101
return if word_hash . empty?
102
102
category = CategoryNamer . prepare_name ( category )
103
- @backend . update_category_training_count ( category , -1 )
104
- @backend . update_total_trainings ( -1 )
105
103
word_hash . each do |word , count |
106
104
next if @backend . total_words < 0
107
105
orig = @backend . category_word_frequency ( category , word ) || 0
@@ -114,6 +112,8 @@ def untrain(category, text)
114
112
@backend . update_category_word_count ( category , -count ) if @backend . category_word_count ( category ) >= count
115
113
@backend . update_total_words ( -count )
116
114
end
115
+ @backend . update_total_trainings ( -1 )
116
+ @backend . update_category_training_count ( category , -1 )
117
117
end
118
118
119
119
# Returns the scores in each category the provided +text+. E.g.,
0 commit comments