Skip to content

Instantly share code, notes, and snippets.

@psychocandy
Created August 4, 2012 15:52
Show Gist options
  • Save psychocandy/3258481 to your computer and use it in GitHub Desktop.
Save psychocandy/3258481 to your computer and use it in GitHub Desktop.
# lib/stop_words.rb:
module StopWords
def stop_words_finder
stop_words = ["ich", "heute"]
end
end
# models/pool.rb:
class Pool < ActiveRecord::Base
attr_accessible :pooltext
include StopWords
end
# controllers/application_controller.rb:
class ApplicationController < ActionController::Base
def foo
pool = Pool.new
stop_words = pool.stop_words_finder
data = %q{Ich gehe heute schwimmen. Und du?}
key_words = data.split.select { |word| !stop_words.include?(word) }
pool.pooltext = key_words.join(' ')
pool.save!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment