On 26.10.2006, at 22:06, Ghost wrote:
> Can someone give me an idiots guide as to how to implement this custom
> stemming analyser. I do not know where to start.
1. Create the analyzer as David outlined it and name the file
"my_analyzer.rb". If you put it in /app/models you don't need any
require statements since every .rb file in /app/models gets
automagically 'required' by Rails.
> # file: app/models/my_analyzer.rb
>
> require 'rubygems'
> require 'ferret'
>
> module Ferret::Analysis
> class MyAnalyzer
> def token_stream(field, text)
> StemFilter.new(StandardTokenizer.new(text))
> end
> end
> end
2. When you create an Index instance, pass it your analyzer, like so:
index = Ferret::I.new(:analyzer => Ferret::Analysis::MyAnalyzer.new)
3. Test your analyzer, e.g.
index << "walking"
index << "walked"
index << "walks"
index.search("walk").total_hits # -> 3
> Thanks for your patience.
You're welcome. And may I kindly ask you to use a valid email address
and perhaps your real name for future posts?
Kind regards,
Andreas
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk