Class: TextRank::TokenFilter::Stopwords
- Inherits:
-
Object
- Object
- TextRank::TokenFilter::Stopwords
- Defined in:
- lib/text_rank/token_filter/stopwords.rb
Overview
Token filter to remove common stop word tokens
= Example
Stopwords.new.filter!(%w[ but for what purpose was the earth formed to drive us mad ]) => ["purpose", "earth", "formed", "drive", "mad"]
Constant Summary collapse
- STOP_WORDS =
Default English stop-word list.
Set.new(YAML.load_file(File.('stopwords.yml', __dir__)))
Instance Method Summary collapse
-
#filter!(tokens) ⇒ Array<String>
Perform the filter.
Instance Method Details
#filter!(tokens) ⇒ Array<String>
Perform the filter
21 22 23 24 25 |
# File 'lib/text_rank/token_filter/stopwords.rb', line 21 def filter!(tokens) tokens.delete_if do |token| STOP_WORDS.include?(token.downcase) end end |