This works on every other term that I can think of… just not the term
“Glass”…
Any ideas?
Hi Clare,
If you are doing this so that you can search for both pluralized and
non-pluralized versions of a term then you’d be better off using
Ferret’s StemFilter. Otherwise, I’ll leave the answer to this up to
the rails people.
Why not set your query to return results on the singular OR the plural
form? Also you can add new inflection rules in the environment.rb
file. Don’t forget to restart the server if you make edits to that
file.
Thank you all for the answers, I added the following line to
enviroment.rb and uncoomented the rest (I played with variations of
commenting/uncommenting) and restarted the server a few times but it
produces glasses OR glas. Id there anything else that i have to do apart
from uncommenting the inflector bit + is there a better way to catch
more than just glass? Would anyone like to share their upgraded
inflector rules for english language?
Inflector.inflections do |inflect|
inflect.irregular ‘glass’, ‘glasses’
inflect.plural /^(ox)$/i, ‘\1en’
inflect.singular /^(ox)en/i, ‘\1’
inflect.irregular ‘person’, ‘people’
inflect.uncountable %w( fish sheep )
end
Why not set your query to return results on the singular OR the plural
form? Also you can add new inflection rules in the environment.rb
file. Don’t forget to restart the server if you make edits to that
file.
Hi Brian,
That’s what using the StemFilter in Ferret will do. Plus it will
search for other forms of the word. For example, “burn” will also
match “burns”, “burned” and “burning”.
I don’t recommend these. You’ll get box / boxen, which is mildly
amusing to dorks like us, but probably not what you intended.
Well, it would if there wasn’t a ^ at the start of that regular
expression. In
any case you don’t get a choice because it’s one of the default rules
which is
already loaded, as mentioned above