Products Technologies Demo Docs Blog Support Company

AutoCorrect: TWo INitial CApitals

In today's mobile world and because of the progress made in AutoCorrect technology in smartphones, users get confused, if their desktop application doesn't provide the same functionality. Using TX Spell .NET, you integrate one of the most powerful spell checking and correction engines into your .NET based applications. Based on the analysis of thousands of documents, the expected suggestion is ranked at position 1 or 2 in more than 97% of all cases. The algorithm includes the measurement of…

AutoCorrect: TWo INitial CApitals

In today's mobile world and because of the progress made in AutoCorrect technology in smartphones, users get confused, if their desktop application doesn't provide the same functionality.

Using TX Spell .NET, you integrate one of the most powerful spell checking and correction engines into your .NET based applications. Based on the analysis of thousands of documents, the expected suggestion is ranked at position 1 or 2 in more than 97% of all cases. The algorithm includes the measurement of the distance between the keys on the currently used keyboard. Many different factors are evaluated and rated to create the accurate list of suggestions.

A popular feature in MS Office is the AutoCorrect feature TWo INitial CApitals. If a word starts with two initial capitals, but the word itself is not misspelled, it will be corrected automatically.

Using TX Text Control and TX Spell .NET, this feature can be easily implemented.

AutoCorrect: TWo INitial CApitals

On the Changed event of TextControl, all misspelled words are checked whether the first two letters are uppercase. If true and the lower case word is not misspelled, the word is corrected by replacing the upper case character with its lower case counterpart. The corrected word is then replaced in TextControl using the MisspelledWords.Remove method.

private void textControl1_Changed(object sender, EventArgs e)
{
    if (correctTWoINitialCApitalsToolStripMenuItem.Checked == false)
        return;

    // loop through all misspelled words
    foreach (MisspelledWord word in textControl1.MisspelledWords)
    {
        // if the first two initials are uppercase
        if (char.IsUpper(word.Text[0]) && char.IsUpper(word.Text[1]))
        {
            // and the word is not mispelled
            txSpellChecker1.Check(word.Text.ToLower());

            // replace the word
            if (txSpellChecker1.IncorrectWords.Count == 0)
                 textControl1.MisspelledWords.Remove(word,
                     ToUpperFirstLetter(word.Text));
        }
    }
}

// returns a string with the first letter uppercase
public static string ToUpperFirstLetter(string source)
{
    if (string.IsNullOrEmpty(source))
        return string.Empty;

    char[] letters = source.ToLower().ToCharArray();
    letters[0] = char.ToUpper(letters[0]);
    return new string(letters);
}

You can download the Visual Studio 2012 project to do your own tests. At least, trials version of TX Spell .NET for Windows Forms and TX Text Control .NET for Windows Forms are required.

Happy coding!

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Related Posts

HTML5Spell CheckingTutorial

Web.TextControl and Spell Checking

In combination with the spell checking component TX Spell .NET for Windows Forms (with ASP.NET support), spell checking can be easily added to web-based applications created with TX Text Control…


ProofingSpell CheckingTutorial

TX Spell .NET: Not Only a Spell Checker

Using TX Spell .NET, you can easily integrate powerful proofing tools into your TX Text Control based applications. The proofing tools for Windows Forms, WPF and ASP.NET doesn't only provide…


Spell CheckingTutorial

TX Spell .NET: Ignore Word List Using User Dictionaries

A unique feature of TX Spell .NET is the possibility to use multiple dictionaries at the same time for the spell checking process. This is valid for language dictionaries and user dictionaries.…


GitHubSpell CheckingTutorial

TX Spell .NET ActiveX Package Released - Spell Checking in VB6

TX Spell .NET ActiveX Package enables you to add high-performance spell checking capabilities to your VB6 applications. Technically, it is based on TX Spell .NET for Windows Forms that gives you…


SampleSpell CheckingTutorial

Porting RapidSpell to TX Spell .NET

Our new spell checking component TX Spell .NET can be easily used to replace RapidSpell in your projects. Integrating TX Spell .NET into TX Text Control based applications is as easy as 1-2-3.…