static void Main(string[] args) { //string testString = "장세기"; //EngToKor etk = new EngToKor(); //Console.WriteLine("입력값 : " + testString); //Console.WriteLine("영문 한글 변환 : " + etk.Trans(testString)); //testString = etk.Trans(testString); //KorToPhoneme ktp = new KorToPhoneme(); //string KeyPhoneme = ktp.Trans(testString); //Console.WriteLine("한글 자소 분리 : " + KeyPhoneme); //AutoComplete bac = new AutoComplete(); //Console.WriteLine("suggest : " + bac.BibleSuggestProcess(KeyPhoneme)); //Console.WriteLine("normal : " + bac.NormalProcess(bac.BibleSuggestProcess(KeyPhoneme))); //Console.WriteLine(); AutoComplete ac = new AutoComplete(); KorToPhoneme ktp = new KorToPhoneme(); string KeyPhoneme = ktp.Trans("우리는"); string[] temp = ac.WorshipSuggestProcess(KeyPhoneme); foreach (string str in temp) { Console.WriteLine(str); } }
// 한글 변환 파싱 된 스트링을 넣으면 가장 확률이 놓은 요소를 반환 public string BibleSuggestProcess(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()); }
public string[] WorshipSuggestProcess(string keyword) { string[] worshopArr = GetFileList(@"찬양집"); KorToPhoneme ktp = new KorToPhoneme(); int[] rank = new int[worshopArr.Length]; int[,] rec = new int[5, 2]; for (var i = 0; i < worshopArr.Length; i++) { // Boundary 를 위해 커팅할 길이 체크 int cutLen; if (worshopArr[i].Length < keyword.Length) { cutLen = worshopArr[i].Length; } else { cutLen = keyword.Length; } string tempStr = ktp.Trans(worshopArr[i]).Substring(0, cutLen); char[] tempCh = tempStr.ToCharArray(); ArrayList tempStrArrList = new ArrayList(); tempStrArrList.AddRange(tempCh); 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] = worshopArr[rec[i, 1]]; } return(rankList); }