Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def wordOccurrences(w: Word): Occurrences = {
- val occMap = w.toLowerCase groupBy (c => c) mapValues( _.size )
- occMap.toList
- }
- /** Converts a sentence into its character occurrence list. */
- def sentenceOccurrences(s: Sentence): Occurrences = {
- val wordOccs = for ( word <- s ) yield wordOccurrences( word )
- wordOccs.toList.flatten
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement