コード例 #1
0
        private bool IsCK(HomophoneGroup homophoneGroup)
        {
            List<string> wordList = new List<string>(homophoneGroup);

            if (wordList.Count == 2)
            {
                if (wordList[0].Replace('c', 'k') == wordList[1])
                {
                    return true;
                }
                else if (wordList[0].Replace('k', 'c') == wordList[1])
                {
                    return true;
                }
            }

            return false;
        }
コード例 #2
0
        private bool IsChsChes(HomophoneGroup homophoneGroup)
        {
            List<string> wordList = new List<string>(homophoneGroup);

            if (wordList.Count == 2)
            {
                if (wordList[0].Length > 3 && wordList[1].Length > 3)
                {
                    if (wordList[0].EndsWith("ches") && wordList[1].EndsWith("chs"))
                    {
                        return true;
                    }
                    else if (wordList[0].EndsWith("chs") && wordList[1].EndsWith("ches"))
                    {
                        return true;
                    }
                }
            }

            return false;
        }
コード例 #3
0
        private void Trim(HomophoneGroup homophoneGroup)
        {
            if (homophoneGroup.Count < 2)
                return;

            HashSet<string> beginingList = new HashSet<string>();

            IEnumerable<string> sortedWordListByLength = from word in homophoneGroup orderby word.Length select word;

            foreach (string word in sortedWordListByLength)
            {
                if (word.Length > beginingLength)
                {
                    if (word.StartsWith(beginingList))
                    {
                        homophoneGroup.Remove(word);
                    }
                    else
                    {
                        beginingList.Add(word.Substring(0, 3));
                    }
                }
            }
        }
コード例 #4
0
 private bool IsDesiredHomophoneGroup(HomophoneGroup homophoneGroup)
 {
     return IsOrEr(homophoneGroup) ||
         IsIseIze(homophoneGroup) ||
         IsIseIzed(homophoneGroup) ||
         IsSC(homophoneGroup) ||
         IsNsNes(homophoneGroup) ||
         IsMsMes(homophoneGroup) ||
         IsLsLes(homophoneGroup) ||
         IsKsKes(homophoneGroup) ||
         IsChsChes(homophoneGroup) ||
         IsRsRes(homophoneGroup) ||
         IsDsDes(homophoneGroup) ||
         IsYsYes(homophoneGroup) ||
         IsBsBes(homophoneGroup) ||
         IsGsGes(homophoneGroup) ||
         IsHsHes(homophoneGroup) ||
         IsWsWes(homophoneGroup) ||
         IsXsXes(homophoneGroup) ||
         IsTsTes(homophoneGroup) ||
         IsFsFes(homophoneGroup) ||
         IsSingZing(homophoneGroup) ||
         IsIY(homophoneGroup) ||
         IsCK(homophoneGroup) ||
         IsVW(homophoneGroup) ||
         IsFPh(homophoneGroup) ||
         IsOsOes(homophoneGroup);
 }
コード例 #5
0
        private bool IsSingZing(HomophoneGroup homophoneGroup)
        {
            List<string> wordList = new List<string>(homophoneGroup);

            if (wordList.Count == 2)
            {
                if (wordList[0].Length > 4 && wordList[1].Length > 4)
                {
                    if (wordList[0].EndsWith("zing") && wordList[1].EndsWith("sing"))
                    {
                        return true;
                    }
                    else if (wordList[0].EndsWith("sing") && wordList[1].EndsWith("zing"))
                    {
                        return true;
                    }
                }
            }

            return false;
        }
コード例 #6
0
        private bool IsSC(HomophoneGroup homophoneGroup)
        {
            List<string> wordList = new List<string>(homophoneGroup);

            if (wordList.Count == 2)
            {
                if (wordList[0].Length > 1 && wordList[1].Length == wordList[0].Length)
                {
                    if (wordList[0].Substring(1) == wordList[1].Substring(1))
                    {
                        if (wordList[0].StartsWith("s") && wordList[1].StartsWith("c"))
                        {
                            return true;
                        }
                        else if (wordList[0].StartsWith("c") && wordList[1].StartsWith("s"))
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }
コード例 #7
0
        private bool IsOrEr(HomophoneGroup homophoneGroup)
        {
            List<string> wordList = new List<string>(homophoneGroup);

            if (wordList.Count == 2)
            {
                if (wordList[0].Length > 2 && wordList[1].Length == wordList[0].Length)
                {
                    if (wordList[0].Substring(0, wordList[0].Length - 2) == wordList[1].Substring(0, wordList[1].Length - 2))
                    {
                        if (wordList[0].EndsWith("er") && wordList[1].EndsWith("or"))
                        {
                            return true;
                        }
                        else if (wordList[0].EndsWith("or") && wordList[1].EndsWith("er"))
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }
コード例 #8
0
        private bool IsIseIzed(HomophoneGroup homophoneGroup)
        {
            List<string> wordList = new List<string>(homophoneGroup);

            if (wordList.Count == 2)
            {
                if (wordList[0].Length > 4 && wordList[1].Length == wordList[0].Length)
                {
                    if (wordList[0].Substring(0, wordList[0].Length - 4) == wordList[1].Substring(0, wordList[1].Length - 4))
                    {
                        if (wordList[0].EndsWith("ised") && wordList[1].EndsWith("ized"))
                        {
                            return true;
                        }
                        else if (wordList[0].EndsWith("ized") && wordList[1].EndsWith("ised"))
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }
コード例 #9
0
        private bool IsFPh(HomophoneGroup homophoneGroup)
        {
            List<string> wordList = new List<string>(homophoneGroup);

            if (wordList.Count == 2)
            {
                if (wordList[0].Replace("f", "ph") == wordList[1])
                {
                    return true;
                }
                else if (wordList[0].Replace("ph", "f") == wordList[1])
                {
                    return true;
                }
            }

            return false;
        }
コード例 #10
0
 /// <summary>
 /// Whether word variant is matching ending type
 /// </summary>
 /// <param name="wordVariant">word variant</param>
 /// <param name="homophoneGroup">homophone group</param>
 /// <returns>Whether word variant is matching ending type</returns>
 private bool IsMatchEndingType(string wordVariant, HomophoneGroup homophoneGroup)
 {
     return IsMatchEndingType(wordVariant, homophoneGroup.GetShortestVariant(wordVariant)) || IsMatchPhoneticEnding(homophoneGroup.PhoneticValue);
 }