python初学者,需要的一个模型是scala格式,如何转成python,请大家帮助。
// subsampling the words : refer to Google's word2vec NIPS paper to understand this
//
if (sample > 0)
sen = sen.filter(id => subSample(id) != -1)
val senLength = sen.size
for (senPosition <- 0 until senLength) {
val currWord = sen(senPosition)
//
// dynamic window-size as in word2vec.
//
val b = rng.nextInt(window)
// make the contexts
//
val contexts = new mutable.ArrayBuffer[Int]
for (a <- b until window * 2 + 1 - b) if (a != window) {
val c = senPosition - window + a
if (c >= 0 && c < senLength)
contexts += sen(c)