问题描述
我在使用以下代码时遇到问题:
'@global': {
'*': {
'scrollbar-width': 'thin',},'*::-webkit-scrollbar': {
width: '1rem',height: '1rem','*::-webkit-scrollbar-thumb': {
backgroundColor: '#d6dee1',borderRadius: '20px',border: "6px solid transparent",backgroundClip: 'content-Box','*::-webkit-scrollbar-thumb:hover': {
backgroundColor: '#a8bbbf'
},'*::-webkit-scrollbar-track': {
backgroundColor: 'transparent',}
}
我收到此错误:
class Review(label: Double,features:org.apache.spark.ml.linalg.Vector)
def transformDataTFIDF(plainText: RDD[String],reviewClass:String,label:Int,numTerms:Int): org.apache.spark.sql.Dataset[Review] = {
val lemmatized = plainText.zipwithIndex.map(_.swap).mapPartitions(iter => {
val pipeline = createNLPPipeline();
iter.map{ case(id,contents) => (id.toString(),plainTextToLemmas(contents,stopWords,pipeline))
};
}).cache()
val (termDocMatrix,termIds,docIds,idfs) = termDocumentMatrix(lemmatized,numTerms,sc)
val vectorizedReviewsMap = Map( reviewClass -> termDocMatrix)
val ReviewsList = MutableList[Review]()
val ReviewsvecRDD = vectorizedReviewsMap(reviewClass).collect().foreach(v => ReviewsList += Review(label,v.asML))
ReviewsList.toDS()
}
你能告诉我该怎么做才能纠正吗?
解决方法
MutableList
一直存在到 Scala 2.12。它在 Scala 2.13 中被删除了你可能没有导入它。试试:
import scala.collection.mutable
val ReviewsList = mutable.MutableList[Review]()
或者:
val ReviewsList = scala.collection.mutable.MutableList[Review]()
Scala 2.12 的工作代码片段和 Scala 2.13 的相同非工作示例。