Counting words for visual details

  • Thread starter PÃ¥l Bergström
  • Start date
P

Pål Bergström

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.)
 
E

Ehsanul Hoque

I save each answer for each user=2C 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=2CWord2=2CWord3.
=20
What would be the best way to count the words picked for let's say
Linear? And also=2C count the ones most frequent.
=20
( 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=2C if you can create the query for the word array=2C then you can simp=
ly use the size() method to count the objects in the array:

word_array =3D ['Word1'=2C 'Word2'=2C 'Word3'] #query here instead
word_array.size # =3D> 3
=0A=
_________________________________________________________________=0A=
Hotmail=AE has ever-growing storage! Don=92t worry about storage limits.=0A=
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=3DTXT_TAGLM_WL_HM_Tuto=
rial_Storage_062009=
 
P

Pål Bergström

Ehsanul said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,242
Latest member
KendrickKo

Latest Threads

Top