I'd just put this into lib/, if you call the file my_analyzer.rb it
should be found and loaded by Rails automatically when you use the
class.
if not, require it explicitly in environment.rb.
Jens
On Tue, Jun 26, 2007 at 04:25:27PM +0200, Chris Brickley wrote:
> Ok thanks for that link. However, I am a bit lost as to where I would
> put my analyzer code? In my model itself or somewhere else?
>
> This is what I came up with:
>
>
> class MyAnalyzer < Analyzer
> def initialize(stop_words = FULL_ENGLISH_STOP_WORDS, lower = true)
> @lower = lower
> @stop_words = stop_words
> end
>
> def token_stream(field, str)
> ts = StandardTokenizer.new(str)
> ts = LowerCaseFilter.new(ts) if @lower
> ts = StopFilter.new(ts, @stop_words)
> ts = HyphenFilter.new(ts)
> ts = ApostropheFilter.new(ts)
> end
> end
>
> class ApostropheFilter
> def next()
> t = @input.next()
>
> if (t == nil)
> return nil
> end
>
> t.term_text = t.term_text.tr("'","")
>
> return t
> end
> end
>
> I tried putting it below my aaf declaration in my model file but I just
> get:
> "NameError: uninitialized constant Ferret::Analysis::MyAnalyzer" when
> trying to do Model.rebuild_index.
>
> Thanks.
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ferret-talk mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/ferret-talk
>
--
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[EMAIL PROTECTED] | www.webit.de
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk