flatMap のデータを使用してマトリックスを初期化したい 、これは私のデータです:
-4,0,1.0 ### horrible . not-work install dozen scanner umax ofcourse . tech-support everytime call . fresh install work error . crummy product crummy tech-support crummy experience .
2,1,1.0 ### scanner run . grant product run windows . live fact driver windows lose performance . setup program alert support promptly quits . amazon . website product package requirement listing compatible windows .
1,2,1.0 ### conversion kit spare battery total better stick versionand radio blow nimh charger battery . combination operation size nimh battery . motorola kit . rechargable battery available flashlight camera game toy .
-4,3,1.0 ### recieive part autowinder catch keep place sudden break . hold listen music winder wind . extremely frustrated fix pull little hard snap half . flush drain .
これは私のコードです:
val spark_context = new SparkContext(conf)
val data = spark_context.textFile(Input)
val Gama=DenseMatrix.zeros[Double](4,2)
var gmmainit = data.flatMap(line => {
val tuple = line.split("###")
val ss = tuple(0)
val re = """^(-?\d+)\s*,\s*(\d+)\s*,\s*(\d+).*$""".r
val re(n1, n2, n3) = ss // pattern match and extract values
if (n1.toInt >= 0) {
Gama(n2.toInt, 0) += 1
}
if (n1.toInt < 0) {
Gama(n2.toInt, 1) += 1
}
})
println(Gama)
しかし、ガマ行列は変わらず、
この問題を解決するためにコードを変更するにはどうすればよいですか?