博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用NHunspell实现拼写检查
阅读量:6183 次
发布时间:2019-06-21

本文共 1972 字,大约阅读时间需要 6 分钟。

First, you need to add "NHunspell" from "NuGet" and import it. The specific operation is as follows

Right click the Reference and select "Manage NuGet Packages...",

 

then type "NHunspell " in the search bar and install it:

 

Second step, you need to create a folder to store ".aff" and ".dic" like this.

 

Download the "zip" containing the corresponding file, you can access

The last step, you can refer to the following code:

Private Sub btCheck_Click(sender As Object, e As EventArgs) Handles btCheck.Click        Dim affFile As String = AppDomain.CurrentDomain.BaseDirectory & "../../Dictionaries/en_us.aff"        Dim dicFile As String = AppDomain.CurrentDomain.BaseDirectory & "../../Dictionaries/en_us.dic"        lbSuggestion.Items.Clear()        lbmorph.Items.Clear()        lbStem.Items.Clear()        Using hunspell As New Hunspell(affFile, dicFile)            Dim correct As Boolean = hunspell.Spell(TextBox1.Text)            checklabel.Text = TextBox1.Text + " is spelled " & (If(correct, "correct", "not correct"))            Dim suggestions As List(Of String) = hunspell.Suggest(TextBox1.Text)            countlabel.Text = "There are " & suggestions.Count.ToString() & " suggestions"            For Each suggestion As String In suggestions                lbSuggestion.Items.Add("Suggestion is: " & suggestion)            Next            Dim morphs As List(Of String) = hunspell.Analyze(TextBox1.Text)            For Each morph As String In morphs                lbmorph.Items.Add("Morph is: " & morph)            Next            Dim stems As List(Of String) = hunspell.Stem(TextBox1.Text)            For Each stem As String In stems                lbStem.Items.Add("Word Stem is: " & stem)            Next        End Using    End Sub

Result:

 

Refer to: 

Besides, the control "TextBox" and "RichTextBox" in WPF can also implements spell checking via displaying wavy lines. For more details, you can refer to .

转载于:https://www.cnblogs.com/jizhiqiliao/p/10245237.html

你可能感兴趣的文章
MD5
查看>>
Android中的ContentProvider和ContentResolver
查看>>
免费云服务器
查看>>
【java】resteasy 使用
查看>>
asterisk meetme 会议实现
查看>>
Mockito入门
查看>>
sentry部署整理
查看>>
Oracle 列名 备注
查看>>
免费申请泛域名 ssl 证书
查看>>
我的网站搭建: (第五天) 分类和归档
查看>>
java合同生成策略
查看>>
IntelliJ IDEA使用Application Server开发普通Java Web项目
查看>>
服务器tomcat的优化
查看>>
C#类和接口、虚方法和抽象方法及值类型和引用类型的区别
查看>>
好文:「大搜车」凭什么获得阿里如此青睐?
查看>>
JDK1.8的HashMap和ConcurrentHashMap
查看>>
mysql 分区与分表
查看>>
java 值传递 数组传递
查看>>
分布式锁
查看>>
<![CDATA[ ]]>
查看>>