Hello,
I want to clean up accented characters in my index, using acts_as_ferret
in a Rails project. I searched this forum, and found the best solution
is to use an analyser.
I created somthing like this:
class PortugueseAnalyzer
include Ferret::Analysis
MAPPING = {
['à','á','â','ã','ä','å','ā','ă'] => 'a',
'æ' => 'ae',
['ď','đ'] => 'd',
['ç','ć','č','ĉ','ċ'] => 'c',
['è','é','ê','ë','ē','ę','ě','ĕ','ė',] => 'e',
['ƒ'] => 'f',
['ĝ','ğ','ġ','ģ'] => 'g',
['ĥ','ħ'] => 'h',
['ì','ì','í','î','ï','ī','ĩ','ĭ'] => 'i',
['į','ı','ij','ĵ'] => 'j',
['ķ','ĸ'] => 'k',
['ł','ľ','ĺ','ļ','ŀ'] => 'l',
['ñ','ń','ň','ņ','ʼn','ŋ'] => 'n',
['ò','ó','ô','õ','ö','ø','ō','ő','ŏ','ŏ'] => 'o',
['œ'] => 'oek',
['ą'] => 'q',
['ŕ','ř','ŗ'] => 'r',
['ś','š','ş','ŝ','ș'] => 's',
['ť','ţ','ŧ','ț'] => 't',
['ù','ú','û','ü','ū','ů','ű','ŭ','ũ','ų'] => 'u',
['ŵ'] => 'w',
['ý','ÿ','ŷ'] => 'y',
['ž','ż','ź'] => 'z'
}
def token_stream(field, string)
return MappingFilter.new(StandardTokenizer.new(string), MAPPING)
end
end
And inserted this code at the end of environment.rb.
Im my model:
acts_as_ferret({ :fields => [ 'name' ] }, :analyzer =>
PortugueseAnalyzer.new)
But this did not work....
Can someone tell me what I did wrong ????
Thanks
Marcello
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk