Github user srowen commented on a diff in the pull request: https://github.com/apache/spark/pull/10152#discussion_r46768436 --- Diff: mllib/src/main/scala/org/apache/spark/mllib/feature/Word2Vec.scala --- @@ -469,7 +469,32 @@ class Word2VecModel private[spark] ( this(Word2VecModel.buildWordIndex(model), Word2VecModel.buildWordVectors(model)) } - private def cosineSimilarity(v1: Array[Float], v2: Array[Float]): Double = { + /** + * get cosineSimilarity of two word. assumed to be from the vocabulary and used after model built, otherwise will error out + * @param v1 one word from the vocabulary + * @param v2 the other word from the vocabulary + * @return the cosinesimilarity score in the vector space of the given two words + */ + def cosineSimilarity(v1: String, v2: String): Double = { + return cosineSimilarity(getVectors(v1), getVectors(v2)) + } + + /** + * get the built vocabulary from the input + * @return a map of word to its index + */ + def getVocabulary:Map[String,Int]={ --- End diff -- Run `dev/lint-scala` to see errors. For instance, this is missing spaces. You don't need `return`
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org