spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkbradley <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-12153][MLlib]add support of arbitrary l...
Date Tue, 08 Dec 2015 18:31:44 GMT
Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10152#discussion_r46992991
  
    --- 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 --
    
    Regardless, as others have said, these extra methods should come in a separate PR.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message