title: How to get a dataframe from word2vec model using spark
body: <p>I am currently working on a sparkling water application and I am a total beginner in spark and h2o.</p>
  
  <p>What I want to do:</p>
  
  <ol>
  <li>loading a input textfile</li>
  <li>create a word2vec model</li>
  <li>create a dataframe with a column <em>word</em> and a column <em>Vector</em></li>
  <li>using the dataframe as input for h2o</li>
  </ol>
  
  <p>By creating the model i get a map, but i don't know how to create a dataframe of it. The output should look like that:</p>
  
  <p><strong>word</strong>   | <strong>Vector</strong></p>
  
  <p>assert | [0.3, 0.4.....]</p>
  
  <p>sense | [0.6, 0.2.....]
  and so on.</p>
  
  <p>This is my code so far: </p>
  
  <pre><code>from pyspark import SparkContext
  from pyspark.mllib.feature import Word2Vec
  from pysparkling import *
  import h2o
  
  from pyspark.sql import SQLContext
  from pyspark.mllib.linalg import Vectors
  from pyspark.sql import Row
  
  
  # Starting h2o application on spark cluster
  hc = H2OContext(sc).start()
  
  # Loading input file
  inp = sc.textFile("examples/custom/text8.txt").map(lambda row: row.split(" "))
  
  # building the word2vec model with a vector size of 10
  word2vec = Word2Vec()
  model = word2vec.setVectorSize(10).fit(inp)
  
  # Sanity check
  model.findSynonyms("property",5)
  
  # assign vector representation (map to variable
  wordVectorsDF = model.getVectors()
  
  # Transform wordVectorsDF word into dataframe
  </code></pre>
  
  <p>Is there any approach to that or functions provided by spark?</p>
  
  <p>Thanks in advance</p>