Yep, you had a point. The logics are wrong, but the issue is conversion. I was fixing the code just right now and I get it working.
- Subtracting c-‘a’ I was dealing with an index, but i had a dictionary and the char is just what I need
- Map the result dividing all values by the num_count, to get the frequency.
Thank you all guys, for help
function generate_frequencies(data::String)
data = replace(strip(lowercase(data)), "\n" => "")
num_count = 0
frequencies = Dict{Char, Int64}()
for c in data
if c >= 'a' && c <= 'z'
if haskey(frequencies, c)
frequencies[c] += 1
num_count += 1
else
frequencies[c] = 0
end
end
end
map!(x -> floor(x / num_count), values(frequencies))
frequencies
end