예제 #1
0
        public string[] WorshipSuggestProcess(string keyword, Boolean worship)
        {
            string[] worshipArr;

            if (worship)
            {
                worshipArr = FileControl.FileControl.worshipList;
            }
            else
            {
                worshipArr = FileControl.FileControl.hymnList;
            }

            KorToPhoneme ktp = new KorToPhoneme();

            int[] rank = new int[worshipArr.Length];
            int[,] rec = new int[5, 2];
            for (var i = 0; i < worshipArr.Length; i++)
            {
                // Boundary 를 위해 커팅할 길이 체크
                int cutLen;
                if (worshipArr[i].Length < keyword.Length)
                {
                    cutLen = worshipArr[i].Length;
                }
                else
                {
                    cutLen = keyword.Length;
                }
                string tempStr = ktp.Trans(worshipArr[i]).Substring(0, cutLen);

                char[] tempCh = tempStr.ToCharArray();

                ArrayList tempStrArrList = new ArrayList();
                tempStrArrList.AddRange(tempCh);
                // 정확히 일치하는 것이 있을 경우
                if (tempStr == keyword)
                {
                    rank[i] = 100;
                }
                for (var j = 0; j < cutLen; j++)
                {
                    if (tempStrArrList.Contains(keyword[j]))
                    {
                        rank[i]++;
                        tempStrArrList.Remove(keyword[j]);
                    }
                }
                MatchRank(ref rec, i, rank[i]++);
            }

            string[] rankList = new string[rec.GetLength(0)];
            for (var i = 0; i < rankList.Length; i++)
            {
                rankList[i] = worshipArr[rec[i, 1]];
            }
            return(rankList);
        }
예제 #2
0
        // 한글 변환 파싱 된 스트링을 넣으면 가장 확률이 놓은 요소를 반환
        public string SuggestProcess(string keyword)
        {
            int          topIndex = 0;
            int          topValue = 0;
            KorToPhoneme ktp      = new KorToPhoneme();

            for (var i = 0; i < Box.BibleList().Count; i++)
            {
                int bibleLen = ktp.Trans(Box.BibleList()[i].ToString()).Length;

                // Boundary 를 위해 커팅할 길이 체크
                int cutLen;
                if (bibleLen < keyword.Length)
                {
                    cutLen = bibleLen;
                }
                else
                {
                    cutLen = keyword.Length;
                }
                string tempStr = ktp.Trans(Box.BibleList()[i].ToString()).Substring(0, cutLen);
                char[] tempCh  = tempStr.ToCharArray();

                ArrayList tempStrArrList = new ArrayList();
                tempStrArrList.AddRange(tempCh);

                int tempMatch = 0;

                for (var j = 0; j < cutLen; j++)
                {
                    if (tempStrArrList.Contains(keyword[j]))
                    {
                        tempMatch++;
                        tempStrArrList.Remove(keyword[j]);
                    }
                }

                // 일치율이 최대인 값을 저장.
                if (topValue < tempMatch)
                {
                    topValue = tempMatch;
                    topIndex = i;
                }
            }
            return(Box.BibleList()[topIndex].ToString());
        }
예제 #3
0
        static void Main(string[] args)
        {
            string testString = "장세기";

            Console.WriteLine("입력값 : " + testString);

            EngToKor etk = new EngToKor();

            Console.WriteLine("영문 한글 변환 : " + etk.Trans(testString));

            testString = etk.Trans(testString);
            KorToPhoneme ktp        = new KorToPhoneme();
            string       KeyPhoneme = ktp.Trans(testString);

            Console.WriteLine("한글 자소 분리 : " + KeyPhoneme);

            BibleAutoComplete bac = new BibleAutoComplete();

            Console.WriteLine("suggest : " + bac.SuggestProcess(KeyPhoneme));
            Console.WriteLine("normal : " + bac.NormalProcess(bac.SuggestProcess(KeyPhoneme)));
            Console.WriteLine();
        }