Results 1 to 2 of 2

Thread: [.NET 3.5+] Spell Checking Library

  1. #1

    Thread Starter
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    [.NET 3.5+] Spell Checking Library

    Attached is a library I created that uses a Google API to retrieve spelling suggestions for text. The attachment is a solution that will compile into a dll.

    Here is an example:

    Code:
    Imports System.Globalization
    Imports System.SpellChecking
    
    Public Sub SpellCheck()
        '//create the spell checking class
        Using checker = New Checker(CultureInfo.CurrentCulture)
            '//create the request
            Dim request = New Request("The folloing text is a tst.")
            request.Multilined = False
            '//you can pass plain text to the check method if desired
            Dim result = checker.Check(request)
            '//check if the spell check errored
            If result.Errored Then
                Console.WriteLine("Spell check errored")
            Else
                If result.HasCorrections Then
                    '//loop through all the corrections
                    For Each c As Correction In result.Corrections
                        '//write out the word that the suggestions are for
                        Console.WriteLine("{0}:", c.Word)
                        If c.HasSuggestions Then
                            For Each s As Suggestion In c.Suggestions
                                '//write out each suggestion for the word
                                Console.WriteLine("{0}{1}", ControlChars.Tab, s.Value)
                            Next
                        Else
                            Console.WriteLine("{0}No suggestions", ControlChars.Tab)
                        End If
                    Next
                Else
                    Console.WriteLine("No corrections")
                End If
            End If
        End Using
    End Sub
    
    And this would be the output:

    Code:
    folloing:
    	fooling
    	filling
    	following
    	falling
    	felling
    tst:
    	test
    	tat
    	ST
    	St
    	st
    I'll leave it up to you to create your own spell checking user interface. As long as you or the user have an internet connection you can spell check.

    Also note that, exposed in the Checker class, is a CheckAsync method so that you can asynchronously spell check. I have also completely documented every member so that nothing should be unclear.
    Attached Files Attached Files
    Last edited by ForumAccount; Jun 25th, 2011 at 09:25 PM. Reason: Applied different styling

  2. #2

    Re: [.NET 3.5+] Spell Checking Library

    Nice contribution there FA! Some people will find this useful.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width