I'm trying to count the amount of occurences of every word in a text to then represent it as a list of tuples.
I've tried by using an accumulator and I've tried by using the concat and filter. What occurs to be the problem is that I'm not sure how to deal with lists inside a list.
I'm not sure how to continue from here, I tried to call the function wordCountt using filter (x /=) on the argument but that wouldn't run for some reason. Would really appreciate some guidance here.
Cheers
type Document = [Sentence]
type WordTally = [(String, Int)]
wordCountt :: Document -> WordTally
wordCountt [] = []
wordCountt [(x:xs), ys] = [(x, length (filter (x ==) (concat [(x:xs), ys])))] ++ wordCountt [xs, ys]```
```wordCountt [["a", "rose", "is", "a", "rose"],["but", "so", "is", "a", "rose"]]
[("a",3),("rose",3),("is",2),("a",2),("rose",2)*** Exception: CompLing.hs:(60,1)-(61,100): Non-exhaustive patterns in function wordCountt```