Counting words for visual details

I’ve made a survey in Rails where I want people to pick three words,
characteristics, from a list of 30 words for 20 different visual
details; linear, organic, symmetry, etc.

I save each answer for each user, with the visual detail in one column
and the three words in an array in a single varchar column. E.g. for
Linear a user doing the survey might pick Word1,Word2,Word3.

What would be the best way to count the words picked for let’s say
Linear? And also, count the ones most frequent.

( Not sure it’s best to ask here or in Rails forum but I suspect it
could be here with some array or hash trick.)

I save each answer for each user, with the visual detail in one column
and the three words in an array in a single varchar column. E.g. for
Linear a user doing the survey might pick Word1,Word2,Word3.

What would be the best way to count the words picked for let’s say
Linear? And also, count the ones most frequent.

( Not sure it’s best to ask here or in Rails forum but I suspect it
could be here with some array or hash trick.)

Well, if you can create the query for the word array, then you can
simply use the size() method to count the objects in the array:

word_array = [‘Word1’, ‘Word2’, ‘Word3’] #query here instead
word_array.size # => 3

Ehsanul H. wrote:

word_array = [‘Word1’, ‘Word2’, ‘Word3’] #query here instead
word_array.size # => 3

Thanks. I forgot to say that I want to count the occurrence of each of
the 30 words. E.g. how many Word1 have they selected for Linearity? How
many Word1 have they selected for Symmetry? And so on.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs