use the classifier gem from
http://classifier.rubyforge.org/
usage:
b = Classifier::Bayes.new 'A', 'B'
b.train_A "diese worte sind eindeutig A"
b.train_B "und alles sonst B"
b.classify "alles alles" # returns B
you can train the classifier based on already tagged content.