Пример #1
0
        public void Expand(PhoneticTable phoneticTable, WordListFile frequentWordListFile)
        {
            string phoneticValue;

            int countBefore;

            do
            {
                countBefore = phoneticTable.Count;
                foreach (string word in frequentWordListFile)
                {
                    if (!phoneticTable.Contains(word))
                    {
                        phoneticValue = null;

                        if (phoneticValue == null)
                            phoneticValue = phoneticConcatenator.TryConcatenate(word, phoneticTable);

                        if (phoneticValue == null)
                            phoneticValue = phoneticSplitter.TrySplit(word, phoneticTable);

                        if (phoneticValue != null)
                            phoneticTable.Add(word, phoneticValue);
                    }
                }
            } while (countBefore != phoneticTable.Count);
        }
Пример #2
0
 /// <summary>
 /// Repair phonetic table
 /// </summary>
 /// <param name="phoneticTable">phonetic table</param>
 public void Repair(PhoneticTable phoneticTable)
 {
     string phoneticEnding;
     string trimmedPhoneticValue;
     foreach (HomophoneGroup homophoneGroup in new List<HomophoneGroup>(phoneticTable))
     {
         foreach (string wordVariant in new HashSet<string>(homophoneGroup))
         {
             if (IsMatchEndingType(wordVariant, homophoneGroup))
             {
                 if (IsMatchWordVariantEnding(wordVariant))
                 {
                     trimmedPhoneticValue = RemoveUndesiredEnding(homophoneGroup.PhoneticValue);
                     phoneticEnding = BuildPhoneticEnding(homophoneGroup.PhoneticValue);
                     homophoneGroup.Remove(wordVariant);
                     phoneticTable.Add(wordVariant, trimmedPhoneticValue + " " + phoneticEnding);
                 }
             }
         }
     }
 }
Пример #3
0
 public void ReplaceEnding(PhoneticTable phoneticTable, string fromEnglish, string fromPhonetic, string toEnglish, string toPhonetic)
 {
     string phoneticValue;
     foreach (HomophoneGroup homophoneGroup in new List<HomophoneGroup>(phoneticTable))
     {
         foreach (string wordVariant in new HashSet<string>(homophoneGroup))
         {
             if (wordVariant.EndsWith(toEnglish))
             {
                 if (homophoneGroup.GetShortestVariant(wordVariant).EndsWith(fromEnglish) && wordVariant != homophoneGroup.GetShortestVariant(wordVariant))
                 {
                     if (homophoneGroup.PhoneticValue.EndsWith(fromPhonetic))
                     {
                         phoneticValue = ReplaceEnding(homophoneGroup.PhoneticValue, fromPhonetic, toPhonetic);
                         homophoneGroup.Remove(wordVariant);
                         phoneticTable.Add(wordVariant, phoneticValue);
                     }
                 }
             }
         }
     }
 }
Пример #4
0
        private void RepairEnding(PhoneticTable phoneticTable, string englishEnding, string phoneticEnding)
        {
            phoneticEnding = phoneticEnding.Trim();

            foreach (HomophoneGroup homophoneGroup in new List<HomophoneGroup>(phoneticTable))
            {
                foreach (string wordVariant in  new HashSet<string>(homophoneGroup))
                {
                    if (wordVariant == homophoneGroup.GetShortestVariant(wordVariant) + englishEnding && wordVariant != homophoneGroup.GetShortestVariant(wordVariant))
                    {
                        homophoneGroup.Remove(wordVariant);
                        phoneticTable.Add(wordVariant, homophoneGroup.PhoneticValue + " " + phoneticEnding);
                    }
                }
            }
        }