输入法继续写之:五笔容错处理~

来源:互联网 发布:域名使用权 编辑:程序博客网 时间:2024/06/04 18:36

因为五笔难学,所以特别对某些字进行容错。。这样可以明显提高输入效率。。

例如:张 五笔全码是XTAY ... 但是XTA也没有其它的字,所以给予容错处理...你输入XTA也可以打出张字。。。当然了,张字的二级简码是XT... 这里只是举例一下。。。

要进行此项处理,首先得提取所有单字4码的词条, code如下:

   Dim BM As String   Dim CI As String   Dim JS As Long, n As Long       Form5.Show       Form5.Label1.Caption = "正在分析编码..."           Set rs = ADO.CreateRecordset("SELECT * FROM YS_WB86")              n = rs.RecordCount            While rs.EOF = False              BM = rs.Fields(0)         CI = rs.Fields(1)                          If Len(BM) = 4 And Len(CI) = 1 Then                           Open App.Path & "/3machk.txt" For Append As #1                 Print #1, Left$(BM, 3); ","; CI            Close #1                  End If                  JS = JS + 1: DoEvents         Form5.ProgressBar1.Value = (JS / n) * 100                  rs.MoveNext                Wend              Form5.Hide


第二步,检查这些词条的前3码是否有别的字,code如下:

   Dim BM As String, diyBM As String   Dim CI As String, diyCI As String   Dim fgDiyCiAlreadyExist As Integer           '载入要分析的词条文件    Open App.Path & "/3machk.txt" For Input As #2                        Do                     Input #2, diyBM, diyCI                        Set rs = ADO.CreateRecordset("SELECT * FROM YS_WB86 where [BianMa] =  '" + diyBM + "'")                        '分析编码是否已经存在            Do While rs.EOF = False                    BM = rs.Fields(0)               CI = rs.Fields(1)                        '如果编码已存在               If BM = diyBM Then                  fgDiyCiAlreadyExist = 1       '完了,编码已经存在               End If                        rs.MoveNext                     Loop            '如果不存在,则可添加            If fgDiyCiAlreadyExist = 0 Then                           Label3.Caption = " “" & diyBM & "”可加为容错码..."                           Open App.Path & "/3ma.txt" For Append As #1                  Print #1, diyBM; ","; diyCI               Close #1                           Else               Label3.Caption = " “" & diyBM & "”已存在,跳过..."            End If                        fgDiyCiAlreadyExist = 0       '清0,为下一次比较作准备            DoEvents                     Loop Until EOF(2) = True                    Close #2


原创粉丝点击