Click here to Skip to main content
15,881,803 members
Articles / Desktop Programming / Windows Forms

i00 Spell Check and Control Extensions - No Third Party Components Required!

Rate me:
Please Sign up or sign in to vote.
4.95/5 (117 votes)
11 Jan 2014Ms-PL16 min read 1.3M   21   266  
Simple to use, open source Spell Checker for .NET
Public Class Hunspell_Syn
    Inherits i00SpellCheck.Synonyms

    Dim LoadedFile As String

    Dim Thes As New NHunspell.MyThes

    Public Overrides Property File() As String
        Get
            Return MyBase.File
        End Get
        Set(ByVal value As String)
            MyBase.File = value
            Thes = Nothing
            If mt_LoadSyn IsNot Nothing AndAlso mt_LoadSyn.IsAlive Then
                mt_LoadSyn.Abort()
            End If
            mt_LoadSyn = New System.Threading.Thread(AddressOf mtLoadSyn)
            mt_LoadSyn.IsBackground = True
            mt_LoadSyn.Name = "Loading synonyms file " & value
            mt_LoadSyn.Start()
        End Set
    End Property

    Dim mt_LoadSyn As Threading.Thread
    Private Sub mtLoadSyn()
        Thes = New NHunspell.MyThes(File)
    End Sub

    Public Overrides Function FindWord(ByVal Word As String) As System.Collections.Generic.List(Of i00SpellCheck.Synonyms.FindWordReturn)
        If Thes Is Nothing Then Return Nothing

        Dim Suggestions = Thes.Lookup(Word)
        If Suggestions Is Nothing Then Return Nothing
        Dim ReturnResult As New List(Of i00SpellCheck.Synonyms.FindWordReturn)
        For Each item In Suggestions.Meanings
            Dim FindWordReturn As New i00SpellCheck.Synonyms.FindWordReturn
            FindWordReturn.TypeDescription = item.Description
            'FindWordReturn.WordType = i00SpellCheck.Synonyms.FindWordReturn.WordTypes.Other
            FindWordReturn.AddRange(item.Synonyms)
            ReturnResult.Add(FindWordReturn)
        Next

        If ReturnResult.Count = 0 Then Return Nothing

        Return ReturnResult
    End Function

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
i00
Software Developer (Senior) i00 Productions
Australia Australia
I hope you enjoy my code. It's yours to use for free, but if you do wish to say thank you then a donation is always appreciated.
You can donate here.

Comments and Discussions