28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/forematter/commands/classify.rb', line 28
def run
load_classifier
puts 'Getting categories'
categories_for(files_with(field)).each { |cat| bayes.add_category(cat) }
if bayes.categories.empty?
$stderr.puts "No categories found in #{field}, unable to classify"
exit 1
else
found = bayes.categories.length
puts "#{found} #{found == 1 ? 'category' : 'categories'} found"
end
puts 'Training classifier'
files_with(field).each { |file| train(file) }
puts 'Classifying files'
files_to_classify.each { |file| file.write if classify(file) }
end
|