Example #1
0
        /// <summary>
        ///     suggestions for a typical fault of spelling, that
        ///		differs with more, than 1 letter from the right form.
        /// </summary>
        private void ReplaceChars(List <Word> tempSuggestion)
        {
            List <string> replacementChars = Dictionary.ReplaceCharacters;

            for (int i = 0; i < replacementChars.Count; i++)
            {
                int    split       = replacementChars[i].IndexOf(' ');
                string key         = replacementChars[i].Substring(0, split);
                string replacement = replacementChars[i].Substring(split + 1);

                int pos = CurrentWord.IndexOf(key, StringComparison.InvariantCulture);
                while (pos > -1)
                {
                    string tempWord = CurrentWord.Substring(0, pos);
                    tempWord += replacement;
                    tempWord += CurrentWord.Substring(pos + key.Length);

                    if (FindWord(ref tempWord))
                    {
                        SuggestWord(tempWord, tempSuggestion);
                    }

                    pos = CurrentWord.IndexOf(key, pos + 1, StringComparison.InvariantCulture);
                }
            }
        }
Example #2
0
        /// <summary>
        ///     split the string into two pieces after every char
        ///		if both pieces are good words make them a suggestion
        /// </summary>
        private void TwoWords(List <Word> tempSuggestion)
        {
            for (int i = 1; i < CurrentWord.Length - 1; i++)
            {
                string firstWord  = CurrentWord.Substring(0, i);
                string secondWord = CurrentWord.Substring(i);

                if (FindWord(ref firstWord) && FindWord(ref secondWord))
                {
                    string tempWord = firstWord + " " + secondWord;
                    SuggestWord(tempWord, tempSuggestion);
                }
            }
        }