I am trying to calculate the average length of words starting with each letter.
I have managed to get the length of all the words beginning with each letter.
val wordMapCount
Array[(String, Int)] = Array((d,30168), (s,66277),(p,28006), (x,14), (e,19273), (w,59977), (z,73), (a,85621), (t,124595), (i,62296), (b,45909), (k,9527), (u,9221), (h,60919), (y,25896), (o,43646), (n,26979), (f,37123), (q,2388), (j,3361), (v,5788), (g,20983), (l,29854), (r,14473), (m,56165), (c,34864))
val letterMapCount
Array[(String, Int)] = Array((d,155127), (s,330535), (p,177717), (x,38), (e,108830), (w,266442), (z,366), (a,280953), (t,476273), (i,142096), (b,203263), (k,45228), (u,42140), (h,242073), (2,376), (y,91801),(o,124698), (n,102174), (f,180722), (q,14144), (j,17261), (v,34619), (g,108461), (l,140429), (r,86426), (m,224474), (c,220884))
I need to divide letterMapCount
with wordMapCount
but can't figure out how to do it.
My output should be similar to this format:
a 2.211
b 3.28
c 5.631
...
z 9.412
Can anyone provide some guidance as to how I can do this?