Class: Moonstone::Filters::Synonymer
- Inherits:
-
QueuedFilter
- Object
- Lucene::Analysis::TokenFilter
- Moonstone::Filter
- QueuedFilter
- Moonstone::Filters::Synonymer
- Defined in:
- lib/moonstone/filters/synonymer.rb
Instance Method Summary collapse
-
#initialize(stream, synonym_hash) ⇒ Synonymer
constructor
A new instance of Synonymer.
- #process(text) ⇒ Object
Methods inherited from QueuedFilter
Methods inherited from Moonstone::Filter
Constructor Details
#initialize(stream, synonym_hash) ⇒ Synonymer
Returns a new instance of Synonymer.
7 8 9 10 |
# File 'lib/moonstone/filters/synonymer.rb', line 7 def initialize(stream, synonym_hash) @synonym_hash = synonym_hash super(stream) end |
Instance Method Details
#process(text) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/moonstone/filters/synonymer.rb', line 12 def process(text) if syns = @synonym_hash[text] if syns.is_a?(String) [text, syns] elsif syns.is_a?(Array) [text].concat syns end else text end end |