// this method is to be deleted because it has same result as GetScore() public static double GetScore2(string inTerm, DoubleVec contextVec, Word2Vec w2vOm) { List <string> inWordList = TermUtil.ToWordList(inTerm); double score = 0.0d; int count = 0; foreach (string word in inWordList) { DoubleVec wordVec = w2vOm.GetWordVec(word); if (wordVec != null) { score += GetCwobScore(wordVec, contextVec); } count++; } // add score first, then calculate the avg. score = score / count; return(score); }
// Average wordVec for a list of words public static DoubleVec GetAvgWordVecForList(IList <string> wordList, Word2Vec word2Vec) { // init the matrix to all zero int dimension = word2Vec.GetDimension(); DoubleVec aveWordVec = new DoubleVec(dimension); int count = 0; foreach (string word in wordList) { DoubleVec wordVec = word2Vec.GetWordVec(word); if (wordVec != null) { aveWordVec.Add(wordVec); } count++; } // calculate the avg. if (count != 0) { aveWordVec.Divide(count); } return(aveWordVec); }