【发布时间】:2016-10-06 01:51:48
【问题描述】:
您好,我想从 Spark 中的字符串中删除停用词。
假设我有输入字符串 "Hello-people",那么我希望输出为 (hello people) 但我得到的是 (hellopeople )
我的代码是:
def processLine(s: String, stopWords: Set[String]): Seq[String] = {
s.replaceAll("[^a-zA-Z ]", "").toLowerCase().split("\\s+")
s.filter(!stopWords.contains(_))
s.toSeq
}
【问题讨论】:
标签: regex scala stop-words