I have an array of structs that i've built by getting a word frequency count for a list of sentences. The output from this is the most popular words per sentence. I need it across all sentences
Here are the structs:
type WordCountStruct struct {
word string
freq int
}
type WordCountStructArray []WordCountStruct
This is a sample of the WordCountStructArray:
[{the 8} {and 8} {to 7} {and 6} {and 6}]
So what this is is an ordered list, for each sentence, of the most common words. I need to group by the key, and sum the values
In the case of the 5 sample set above, this would result in:
[{the 8} {to 7} {and 20}]
I can convert the struct to a []map[string]interface{} if this is easier?