How to append classes for dynamic terms in jquery?
I hope below code works for you.

if ($('.rate-widget-fivestar').hasClass('rate-widget-1')) {
  $(this).addClass('class1');
}

if ($('.rate-widget-fivestar').hasClass('rate-widget-2')) {
  $(this).addClass('class2');
}

if ($('.rate-widget-fivestar').hasClass('rate-widget-3')) {
  $(this).addClass('class3');
}