Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the startus of the training/untraining when run #137

Merged
merged 1 commit into from
Jan 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/classifier-reborn/bayes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ def train(category, text)
end
end

@backend.update_category_training_count(category, 1)
@backend.update_total_trainings(1)
word_hash.each do |word, count|
@backend.update_category_word_frequency(category, word, count)
@backend.update_category_word_count(category, count)
@backend.update_total_words(count)
end
@backend.update_total_trainings(1)
@backend.update_category_training_count(category, 1)
end

# Provides a untraining method for all categories specified in Bayes#new
Expand All @@ -100,8 +100,6 @@ def untrain(category, text)
word_hash = Hasher.word_hash(text, @language, @enable_stemmer)
return if word_hash.empty?
category = CategoryNamer.prepare_name(category)
@backend.update_category_training_count(category, -1)
@backend.update_total_trainings(-1)
word_hash.each do |word, count|
next if @backend.total_words < 0
orig = @backend.category_word_frequency(category, word) || 0
Expand All @@ -114,6 +112,8 @@ def untrain(category, text)
@backend.update_category_word_count(category, -count) if @backend.category_word_count(category) >= count
@backend.update_total_words(-count)
end
@backend.update_total_trainings(-1)
@backend.update_category_training_count(category, -1)
end

# Returns the scores in each category the provided +text+. E.g.,
Expand Down