【发布时间】:2015-10-23 01:55:55
【问题描述】:
所以,我正在查看 Typesafe Activator 教程和it says
使用的正则表达式;
类似的非字母数字替代\W+,效果不佳
使用非 UTF8 字符集!
这似乎是一件很奇怪的事情。
原评论全文:
// Split on non-alphabetic sequences of characters. Note the regex used;
// the similar, non-alphanumeric alternative """\W+""", does not work well
// with non-UTF8 character sets!
以及后面的代码:
val wc = input
.flatMap(line => line.split("""[^\p{IsAlphabetic}]+"""))
.map(word => (word, 1))
.reduceByKey((count1, count2) => count1 + count2)
\W 和非 UTF8 字符集有什么问题?
【问题讨论】: