MIT6824-Lab1-P2

Part II: Single-worker word count

就是自己编写mapF()reduceF().
关键是如何分割出Word, 这里的定义是:

A word is any contiguous sequence of letters, as determined by unicode.IsLetter.

下面这个分割方式可以通过测试:

tmps := strings.FieldsFunc(contents, func(ch rune) bool {
    return !unicode.IsLetter(ch)
})

可通过测试. 笔者曾按空白分割字符串, 如何检查string是否全是letter来判断是否是字符,这样的做法会导致如下:

"it's"        // 应该是 "it", "s"
"however,""   // "however"

等字符串被判断为不是word.

你可能感兴趣的:(分布式)