Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 Spark MLlib 来训练特定领域的 word2vec 模型,我需要以 glove word2vec 格式使用它。如何将其转换为手套 txt 格式?
在 SparkShell 中尝试了一下之后,我发现下面的代码对我有用:
val vectors = model.getVectors val writer = new BufferedWriter(new FileWriter(file)) vectors foreach ( entry => writer.write(entry._1 + " " + entry._2.mkString(" ") + "\n") )