title: Spark MLib Word2Vec Error: The vocabulary size should be > 0
body: <p>I am trying to implement word vectorization using Spark's MLLib. I am following the example given <a href="http://spark.apache.org/docs/latest/mllib-feature-extraction.html#example" rel="nofollow noreferrer">here</a>.</p>
  
  <p>I have bunch of sentences which I want to give as input to train the model. But am not sure if this model takes sentences or just takes all the words as a sequence of string. </p>
  
  <p>My input is as below:</p>
  
  <pre><code>scala&gt; v.take(5)
  res31: Array[Seq[String]] = Array(List([WrappedArray(0_42)]), List([WrappedArray(big, baller, shoe, ?)]), List([WrappedArray(since, eliud, win, ,, quick, fact, from, runner, from, country, kalenjins, !, write, ., happy, quick, fact, kalenjins, location, :, kenya, (, kenya's, western, highland, rift, valley, ), population, :, 4, ., 9, million, ;, compose, 11, subtribes, language, :, kalenjin, ;, swahili, ;, english, church, :, christianity, ~, africa, inland, church, [, aic, ],, church, province, kenya, [, cpk, ],, roman, catholic, church, ;, islam, translation, :, kalenjin, translate, ", tell, ", formation, :, wwii, ,, gikuyu, tribal, member, wish, separate, create, identity, ., later, ,, student, attend, alliance, high, school, (, first, british, public, school, kenya, ), form, ...
  </code></pre>
  
  <p>But when I try to train my word2vec model on this input it does not work.</p>
  
  <pre><code>scala&gt; val word2vec = new Word2Vec()
  word2vec: org.apache.spark.mllib.feature.Word2Vec = org.apache.spark.mllib.feature.Word2Vec@51567040
  
  scala&gt; val model = word2vec.fit(v)
  java.lang.IllegalArgumentException: requirement failed: The vocabulary size should be &gt; 0. You may need to check the setting of minCount, which could be large enough to remove all your words in sentences.
  </code></pre>
  
  <p>Does <code>Word2Vec</code> not take sentences as input?</p>