Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Global: Averaging Usefulness of Reviews

Quote Reply
Global: Averaging Usefulness of Reviews
Hey all,

I'm looking for a Global that will return a single value that reflects the usefulness of a review. On the reviews there's an option to indicate whether a review was useful or not. Depending on what you choose it increments either the Review_WasHelpful or Review_WasNotHelpful fields.

sounds like it should be easy from this to figure the total number of votes submitted and which percentage was positive.

Below is a piece of code I use to return a value based on the rating average (which is already calculated by the script). I'd like to return a single percentage value for the "usefulness" as well to display a graphic star-indicator.

Can you help?

Code:
sub {
my ($rec) = @_;
if ($rec->{'Rating'} eq '10.00') {'50'; }
elsif ($rec->{'Rating'} eq '0.00') {'00'; }
elsif ($rec->{'Rating'} eq '') {'00'; }
elsif ($rec->{'Rating'} le '0.25') {'00'; }
elsif ($rec->{'Rating'} le '0.50') {'05'; }
elsif ($rec->{'Rating'} le '0.75') {'05'; }
elsif ($rec->{'Rating'} le '1.00') {'05'; }
elsif ($rec->{'Rating'} le '1.25') {'05'; }
elsif ($rec->{'Rating'} le '1.50') {'10'; }
elsif ($rec->{'Rating'} le '1.75') {'10'; }
elsif ($rec->{'Rating'} le '2.00') {'10'; }
elsif ($rec->{'Rating'} le '2.25') {'10'; }
elsif ($rec->{'Rating'} le '2.50') {'15'; }
elsif ($rec->{'Rating'} le '2.75') {'15'; }
elsif ($rec->{'Rating'} le '3.00') {'15'; }
elsif ($rec->{'Rating'} le '3.25') {'15'; }
elsif ($rec->{'Rating'} le '3.50') {'20'; }
elsif ($rec->{'Rating'} le '3.75') {'20'; }
elsif ($rec->{'Rating'} le '4.00') {'20'; }
elsif ($rec->{'Rating'} le '4.25') {'20'; }
elsif ($rec->{'Rating'} le '4.50') {'25'; }
elsif ($rec->{'Rating'} le '4.75') {'25'; }
elsif ($rec->{'Rating'} le '5.00') {'25'; }
elsif ($rec->{'Rating'} le '5.25') {'25'; }
elsif ($rec->{'Rating'} le '5.50') {'30'; }
elsif ($rec->{'Rating'} le '5.75') {'30'; }
elsif ($rec->{'Rating'} le '6.00') {'30'; }
elsif ($rec->{'Rating'} le '6.25') {'30'; }
elsif ($rec->{'Rating'} le '6.50') {'35'; }
elsif ($rec->{'Rating'} le '6.75') {'35'; }
elsif ($rec->{'Rating'} le '7.00') {'35'; }
elsif ($rec->{'Rating'} le '7.25') {'35'; }
elsif ($rec->{'Rating'} le '7.50') {'40'; }
elsif ($rec->{'Rating'} le '7.75') {'40'; }
elsif ($rec->{'Rating'} le '8.00') {'40'; }
elsif ($rec->{'Rating'} le '8.25') {'40'; }
elsif ($rec->{'Rating'} le '8.50') {'45'; }
elsif ($rec->{'Rating'} le '8.75') {'45'; }
elsif ($rec->{'Rating'} le '9.00') {'45'; }
elsif ($rec->{'Rating'} le '9.25') {'45'; }
elsif ($rec->{'Rating'} le '9.50') {'50'; }
elsif ($rec->{'Rating'} le '9.75') {'50'; }
else {'50'; }
}

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Global: Averaging Usefulness of Reviews In reply to
I'm not quite following here.

There is a problem with the was/was_not useful, in that clicking on it mulitple times increments it repeatedly. That can easily distort the counts.

The "rate" system doesn't really do a good job of averaging the rates/votes for a link. I've offered a couple of suggestions over a year ago, but never implemented them beyond the logging stage. I'll have a better rate.cgi out shortly, that keeps track of each rating, and does a true average, and allows one vote per user per link. Flexibility has been the problem, and I'll have to make some assumptions, I guess.

I'm not following how you'd correlate the "usefulness" with the "ratings" to get a meaningful value, though.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Global: Averaging Usefulness of Reviews In reply to
Pugdog thanks for all your replies! English is my 3rd of 7 languages and I think I may not have explained this one very well. Tongue

Not trying to correlate usefulness with ratings, I'm merely trying to do something similar for usefulness as the what the piece of code above does for ratings. Also, if the results are slightly out, that's OK. I can approve them later as smart people like you come up with better solutions! Wink

So, I'm basically trying to calculate the percentage positive votes received for each review, using the fields I already have. (trying to make as few changes as possible) I'll need a global like the one above I assume.

The logic should go something like:

- (was_useful + was_notuseful) = Total Votes
- (was_useful/Total Votes) * 100/1 = Percentage_Useful
- Return Percentage_Useful as a Tag

This way I can add a graphic called: <img src="<%build_images_url%>/default/stars-<%Percentage_Useful%>.gif"> to my templates and get a nice star rating showing the relative usefulness of a review. Same as the stars currently avaiable as default for review ratings.

Calculating an actual percentage is probably not even necessary. I could work with a single decimal value as well. Now if you look at the global I provided again you'll see that it does this but for Ratings. I had to use this global before ratings had a default star system as in version 2.1.0.

Does this help?

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Global: Averaging Usefulness of Reviews In reply to
Hi,

How about:

Code:
HowHelpful => sub {
my $tags = shift;
my $useful = $tags->{Review_WasHelpful};
my $notuseful = $tags->{Review_WasNotHelpful};
return "0" if (! $useful);
return "100" if (! $notuseful);
my $percent = $useful / ($useful + $notuseful);
my $round = (int($percent * 20 + 0.5) / 20) * 100;
return $round;
}

Which gives you 0, 5, 10, 15, ... , 95, 100.

Hope that helps,

Alex
--
Gossamer Threads Inc.

Last edited by:

Inertia: Nov 4, 2008, 3:50 PM
Quote Reply
Re: [Alex] Global: Averaging Usefulness of Reviews In reply to
Thanks Alex - looks like a nice clean solution. One more question. Your default star images follow the following naming convention: stars-1.gif, stars-1-5.gif .... though stars-5.gif.

Would be helpful to tweak the output of your pirce of code to follow this convention. 1, 1-5.... 5.

Can you help?

Safe swoops
Sangiro