コード例 #1
0
        public static HashSet <MergeObj> GetCandidates(int tarPos, List <TokenObj> nonSpaceTextList, CSpellApi cSpellApi)
        {
            // 0. get vars from cSpellApi
            RootDictionary suggestDic = cSpellApi.GetSuggestDic();
            RootDictionary aADic      = cSpellApi.GetAaDic();
            RootDictionary mwDic      = cSpellApi.GetMwDic();
            // get all merge candidates, recursively
            HashSet <MergeObj> mergeSet = new HashSet <MergeObj>();
            int maxMergeNo = cSpellApi.GetCanRwMaxMergeNo();
            // default: no merge with hyphen for real-word
            bool mergeWithHyphen = cSpellApi.GetCanRwMergeWithHyphen();
            // go through all merge no
            // set no shrot word merge: exclude me at => meat
            bool shortWordMerge = false;

            for (int mergeNo = 1; mergeNo <= maxMergeNo; mergeNo++)
            {
                HashSet <MergeObj> curMergeSet = CandidatesUtilMerge.GetMergeSetByMergeNo(tarPos, nonSpaceTextList, mergeNo, mergeWithHyphen, shortWordMerge, suggestDic, aADic, mwDic);
                // add valid merge candidate
                foreach (MergeObj mergeObj in curMergeSet)
                {
                    if (IsValidMergeCand(mergeObj, cSpellApi) == true)
                    {
                        mergeSet.Add(mergeObj);
                    }
                }
            }
            return(mergeSet);
        }
コード例 #2
0
        public static HashSet <MergeObj> GetCandidates(int tarPos, List <TokenObj> nonSpaceTextList, CSpellApi cSpellApi)
        {
            // 0. get vars from cSpellApi
            RootDictionary suggestDic = cSpellApi.GetSuggestDic();
            RootDictionary aADic      = cSpellApi.GetAaDic();
            RootDictionary mwDic      = cSpellApi.GetMwDic();
            // get all merge candidates, recursively
            HashSet <MergeObj> mergeSet = new HashSet <MergeObj>();
            int maxMergeNo = cSpellApi.GetCanNwMaxMergeNo();
            // default: non-word includes merge with hyphen
            bool mergeWithHyphen = cSpellApi.GetCanNwMergeWithHyphen();
            // allow short word merge: a m => am
            bool shortWordMerge = true;

            for (int mergeNo = 1; mergeNo <= maxMergeNo; mergeNo++)
            {
                HashSet <MergeObj> curMergeSet = CandidatesUtilMerge.GetMergeSetByMergeNo(tarPos, nonSpaceTextList, mergeNo, mergeWithHyphen, shortWordMerge, suggestDic, aADic, mwDic);
                mergeSet.addAll(curMergeSet);
            }
            return(mergeSet);
        }