Forum: Ruby on Rails Acts_as_taggable pluralize

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Lon B. (Guest)
on 2006-02-14 00:14
I am implementing a messaging system, which requires broadcast to group
feature.

Instead of a relatively clunky habtm group structure, I am using tags.
Form a usability standpoint, it would be helpful to avoid redundant
tags. Like, friend vs friends OR client vs. clients.

Is it practical to filter tags, before entry, to avoid duplicate tags
like plural vs. singular?
joey__ (Guest)
on 2006-02-14 00:35
Lon B. wrote:
> I am implementing a messaging system, which requires broadcast to group
> feature.
>
> Instead of a relatively clunky habtm group structure, I am using tags.
> Form a usability standpoint, it would be helpful to avoid redundant
> tags. Like, friend vs friends OR client vs. clients.
>
> Is it practical to filter tags, before entry, to avoid duplicate tags
> like plural vs. singular?

You could a like search:
Tag.find(:first, :conditions => ['name % ?',params[:tag]]

Or could create a method like:

def Tag.find_with_plurals(tag)
  t = Tag.find_by_name(tag)
  if t.nil?
    t = Tag.find_by_name(tag.pluralize)
  end
  if t.nil?
    t = Tag.create(:name => tag)
  end
  return t
end

Thats untested, so it may not work as is, but it gives you a basic idea.

joey__
Andrew Otwell (Guest)
on 2006-02-14 00:40
(Received via mailing list)
>Instead of a relatively clunky habtm group structure, I am using tags.
>Form a usability standpoint, it would be helpful to avoid redundant
>tags. Like, friend vs friends OR client vs. clients.
>
>Is it practical to filter tags, before entry, to avoid duplicate tags
>like plural vs. singular?

Before entry? You might look at the auto_complete function to suggest
existing tags.

One bit of advice: be careful assuming that tags are a "usable"
replacement for a habtm relationship. "friend" and "friends" may seem
redundant to you, but to a user, those are clearly very different
concepts. I wouldn't tag a portrait photo of my buddy Bob with "friends"
in Flickr if I had the choice. Would you also try to assume thinks like
"myfriends" is redundant with "friends"? The best tagging
implementations don't impose any kinds of restrictions on the text. If
what you need is a traditional categorization system, there are good
examples of usable ways of managing those.
joey__ (Guest)
on 2006-02-14 00:45
Andrew Otwell wrote:
>>Instead of a relatively clunky habtm group structure, I am using tags.
>>Form a usability standpoint, it would be helpful to avoid redundant
>>tags. Like, friend vs friends OR client vs. clients.
>>
>>Is it practical to filter tags, before entry, to avoid duplicate tags
>>like plural vs. singular?
>
> Before entry? You might look at the auto_complete function to suggest
> existing tags.
>
> One bit of advice: be careful assuming that tags are a "usable"
> replacement for a habtm relationship. "friend" and "friends" may seem
> redundant to you, but to a user, those are clearly very different
> concepts. I wouldn't tag a portrait photo of my buddy Bob with "friends"
> in Flickr if I had the choice. Would you also try to assume thinks like
> "myfriends" is redundant with "friends"? The best tagging
> implementations don't impose any kinds of restrictions on the text. If
> what you need is a traditional categorization system, there are good
> examples of usable ways of managing those.

Thats a good idea, with the autocomplete. Or you could modify the method
to return an array, and say did you mean 'list of tags', then they could
choose a pre-exisitng tag, or make a new one.
Lon B. (Guest)
on 2006-02-14 01:01
Andrew Otwell wrote:
> Before entry? You might look at the auto_complete function to suggest
> existing tags.
>
> One bit of advice: be careful assuming that tags are a "usable"
> replacement for a habtm relationship. "friend" and "friends" may seem
> redundant to you, but to a user, those are clearly very different
> concepts. I wouldn't tag a portrait photo of my buddy Bob with "friends"
> in Flickr if I had the choice. Would you also try to assume thinks like
> "myfriends" is redundant with "friends"? The best tagging
> implementations don't impose any kinds of restrictions on the text. If
> what you need is a traditional categorization system, there are good
> examples of usable ways of managing those.

I attempt to apply tagging in a collaborative business environment.
Allow a freeform environment for users to define "groups" of existing
contact records, without imposing a rigid pre-defined group metaphor.

But, the obvious issue being, one user might enter friend vs another
user entering friends, within the same shared data set.

The auto-complete field is helpful, but may not prevent errors in entry
completely.

The idea is more of an experiment, and after some real usage may or may
not be handy.

 Thanks for all the helpful suggestions!
Vivek K. (Guest)
on 2006-02-15 05:50
(Received via mailing list)
>
> The idea is more of an experiment, and after some real usage may or may
> not be handy.


I think you should try the rails Inflections module.Rails itself uses
pluaralization and that could be of  help to you.Also  IMHO I think you
should only use the pluralization  to record somewhere on your system
that
friends and friend are related.A user should be allowed to tag either
friend
or friends but what ever computation you do based on those tags shouldnt
produce very different results.
Vivek
This topic is locked and can not be replied to.