Skip to content

Commit

Permalink
Scope ngramsBuf into each line.
Browse files Browse the repository at this point in the history
  • Loading branch information
concretevitamin committed May 15, 2015
1 parent 5fb6499 commit 21622b8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/scala/nodes/nlp/ngrams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ case class NGramsFeaturizer[@specialized(Int) T: ClassTag](orders: Seq[Int])

override def apply(in: RDD[Seq[T]]): RDD[Seq[Seq[T]]] = {
in.mapPartitions { lines =>
val ngramsBuf = new ArrayBuffer[Seq[T]]()
val ngramBuf = new ArrayBuffer[T](orders.max)
var j = 0
var order = 0
lines.foreach { tokens =>
lines.map { tokens =>
val ngramsBuf = new ArrayBuffer[Seq[T]]()
var i = 0
while (i + minOrder <= tokens.length) {
ngramBuf.clear()
Expand All @@ -54,8 +54,8 @@ case class NGramsFeaturizer[@specialized(Int) T: ClassTag](orders: Seq[Int])
}
i += 1
}
ngramsBuf
}
Iterator.single(ngramsBuf)
}
}

Expand Down

0 comments on commit 21622b8

Please sign in to comment.