Esempio n. 1
0
        // return candidate scoreObj list sorted by score, higher first
        public static List <CSpellScore> GetCandidateScoreList(string wordStr, HashSet <string> candidates, WordWcMap wordWcMap, int tarPos, int tarSize, List <TokenObj> nonSpaceTokenList, Word2Vec word2VecIm, Word2Vec word2VecOm, bool word2VecSkipWord, int contextRadius, int compareMode, double wf1, double wf2, double wf3, bool debugFlag)
        {
            HashSet <CSpellScore> candScoreSet  = GetCandidateScoreSet(wordStr, candidates, wordWcMap, tarPos, tarSize, nonSpaceTokenList, word2VecIm, word2VecOm, word2VecSkipWord, contextRadius, wf1, wf2, wf3, debugFlag);
            List <CSpellScore>    candScoreList = new List <CSpellScore>(candScoreSet);
            // sort the set to list by context
            CSpellScoreNw1To1Comparator <CSpellScore> csc = new CSpellScoreNw1To1Comparator <CSpellScore>();

            csc.SetCompareMode(compareMode);
            candScoreList.Sort(csc);
            return(candScoreList);
        }
 // this detail does not print how cSpell really fidn the top rank
 // it is sorted by CSpell score
 // CSpell use the cSpell score + context and frequency to find the top
 public static void PrintCSpellScore(string inStr, HashSet <string> candSet, WordWcMap wordWcMap, int maxCandNo, int tarPos, int tarSize, List <TokenObj> nonSpaceTokenList, Word2Vec word2VecIm, Word2Vec word2VecOm, bool word2VecSkipWord, int contextRadius, double wf1, double wf2, double wf3, bool debugFlag)
 {
     if (debugFlag == true)
     {
         // NW 1To1
         CSpellScoreNw1To1Comparator <CSpellScore> csc = new CSpellScoreNw1To1Comparator <CSpellScore>();
         HashSet <CSpellScore> cScoreSet = RankByCSpellNonWord.GetCandidateScoreSet(inStr, candSet, wordWcMap, tarPos, tarSize, nonSpaceTokenList, word2VecIm, word2VecOm, word2VecSkipWord, contextRadius, wf1, wf2, wf3, debugFlag);
         var list = cScoreSet.OrderBy(x => x, csc).Take(maxCandNo).Select(obj => obj.ToString()).ToList();
         foreach (var item in list)
         {
             DebugPrint.PrintScore(item, debugFlag);
         }
     }
 }