Class: Raingrams::NgramSet
Instance Method Summary collapse
- #ends_with(gram) ⇒ Object
- #including(gram) ⇒ Object
- #including_all(*grams) ⇒ Object
- #including_any(*grams) ⇒ Object
- #postfixed_by(postfix) ⇒ Object
- #prefixed_by(prefix) ⇒ Object
- #select(&block) ⇒ Object
- #starts_with(gram) ⇒ Object
Instance Method Details
#ends_with(gram) ⇒ Object
30 31 32 |
# File 'lib/raingrams/ngram_set.rb', line 30 def ends_with(gram) select { |ngram| ngram.ends_with?(gram) } end |
#including(gram) ⇒ Object
34 35 36 |
# File 'lib/raingrams/ngram_set.rb', line 34 def including(gram) select { |ngram| ngram.include?(gram) } end |
#including_all(*grams) ⇒ Object
42 43 44 |
# File 'lib/raingrams/ngram_set.rb', line 42 def including_all(*grams) select { |ngram| ngram.includes_all?(*grams) } end |
#including_any(*grams) ⇒ Object
38 39 40 |
# File 'lib/raingrams/ngram_set.rb', line 38 def including_any(*grams) select { |ngram| ngram.includes_any?(*grams) } end |
#postfixed_by(postfix) ⇒ Object
22 23 24 |
# File 'lib/raingrams/ngram_set.rb', line 22 def postfixed_by(postfix) select { |ngram| ngram.postfixed_by?(postfix) } end |
#prefixed_by(prefix) ⇒ Object
18 19 20 |
# File 'lib/raingrams/ngram_set.rb', line 18 def prefixed_by(prefix) select { |ngram| ngram.prefixed_by?(prefix) } end |
#select(&block) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/raingrams/ngram_set.rb', line 8 def select(&block) selected_ngrams = self.class.new each do |ngram| selected_ngrams << ngram if block.call(ngram) end return selected_ngrams end |
#starts_with(gram) ⇒ Object
26 27 28 |
# File 'lib/raingrams/ngram_set.rb', line 26 def starts_with(gram) select { |ngram| ngram.starts_with?(gram) } end |