⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 分词界面.frm

📁 用VB与数据库相连接实现中 文分词的程序
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "中文信息处理——中文分词"
   ClientHeight    =   5460
   ClientLeft      =   3525
   ClientTop       =   2790
   ClientWidth     =   7665
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5460
   ScaleWidth      =   7665
   Begin VB.TextBox Text1 
      Appearance      =   0  'Flat
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   5535
      Left            =   0
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   2
      Top             =   0
      Width           =   3855
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   3960
      Top             =   480
      Visible         =   0   'False
      Width           =   2040
      _ExtentX        =   3598
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\中文分词\词库.mdb;Persist Security Info=False"
      OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\中文分词\词库.mdb;Persist Security Info=False"
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source="
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   5535
      Left            =   3840
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   0
      Top             =   0
      Width           =   3855
   End
   Begin VB.OLE OLE1 
      Height          =   615
      Left            =   2040
      TabIndex        =   1
      Top             =   2400
      Width           =   615
   End
   Begin VB.Menu 关闭 
      Caption         =   "关闭"
   End
   Begin VB.Menu 分词 
      Caption         =   "分词"
      Index           =   2
   End
   Begin VB.Menu 说明 
      Caption         =   "说明"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim pstr As String

Private Sub 分词_Click(Index As Integer)
 Dim key As String
 Dim tmp As String
 Dim n, i, l, tag, cnt As Integer
 
 cnt = 0         '分词前词数为0
 Text2.Text = "分词结果如下:" & Chr(13) & Chr(10) '分词前左边文本为空
 l = Len(Text1.Text)
 tmp = Trim(Text1.Text)
 
 While l > 0
 
 tag = 0 'tag为0,表示没有找到匹配的词
'采用正向最大匹配算法进行分词
'由于词库中最长的词长为13,故设n的初值为13
 For n = 18 To 2 Step -1
 
 key = Left$(tmp, n)
 '词长大于4,在数据表5、6、7、8-11、13-14或18中查找
 If n > 4 Then
    If n = 5 Then
        Adodc1.RecordSource = "select word from 5 where word='" & key & "'"
        Adodc1.Refresh
    End If
    If n = 6 Then
        Adodc1.RecordSource = "select word from 6 where word='" & key & "'"
        Adodc1.Refresh
    End If
    If n = 7 Then
        Adodc1.RecordSource = "select word from 7 where word='" & key & "'"
        Adodc1.Refresh
    End If
    If n >= 8 And n <= 11 Then
        Adodc1.RecordSource = "select word from 8_11 where word='" & key & "'"
        Adodc1.Refresh
    End If
    If n = 13 Or n = 14 Then
        Adodc1.RecordSource = "select word from 13_14 where word='" & key & "'"
        Adodc1.Refresh
    End If
    If n = 18 Then
        Adodc1.RecordSource = "select word from 18 where word='" & key & "'"
        Adodc1.Refresh
    End If
 End If
 '词长为4,在数据表4中查找
 If n = 4 Then
 Adodc1.RecordSource = "select word from 4 where word='" & key & "'"
 Adodc1.Refresh
 End If
 '词长为3,在数据表3中查找
 If n = 3 Then
 Adodc1.RecordSource = "select word from 3 where word='" & key & "'"
 Adodc1.Refresh
 End If
 '词长为2,在数据表2中查找
 If n = 2 Then
 Adodc1.RecordSource = "select word from 2 where word='" & key & "'"
 Adodc1.Refresh
 End If
 
 If Adodc1.Recordset.EOF = False Then
    If key = Trim(Adodc1.Recordset.Fields("word")) Then '找到匹配的词
        cnt = cnt + 1 '找到词的个数加1
        Text2.Text = Text2.Text & cnt & ". " & Chr(9) & Trim(Adodc1.Recordset.Fields("word")) & Chr(13) & Chr(10)
        tag = 1
        Exit For
    Else
        If n = 18 Then
            n = 14
        End If
    End If
 End If
 Next n
 
  
 If tag = 0 Then
 '词长为1,在数据表1中查找
    Adodc1.RecordSource = "select word from 1 where word='" & key & "'"
    Adodc1.Refresh
 
    key = Left$(tmp, 1)
 
    Adodc1.RecordSource = "select word from 1 where word='" & key & "'"
    Adodc1.Refresh
 
    If Adodc1.Recordset.EOF = False Then
        If key = Trim(Adodc1.Recordset.Fields("word")) Then '找到匹配的词
            cnt = cnt + 1 '找到词的个数加1
            Text2.Text = Text2.Text & cnt & ". " & Chr(9) & Trim(Adodc1.Recordset.Fields("word")) & Chr(13) & Chr(10)
            n = 1
        End If
    End If
 End If
 l = l - n
 
 If l < 0 Then
    l = 0
 End If
 
 tmp = Right$(tmp, l)
  
Wend
 
End Sub

Private Sub 关闭_Click()
 If MsgBox("确定退出吗?", vbOKCancel + vbQuestion, "退出系统") = vbOK Then End
End Sub

Private Sub 说明_Click()
 
 MsgBox "wn" & Chr(13) & Chr(10) & "2006", , "说明"

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -