Access 如何利用Word对一段文字进行分词 一、问题描述:
- 2021-10-23
- 来源/作者: 菜鸟图库/ 菜鸟图库
- 350 次浏览
一、问题描述:
现在有一串字符串内容,想自动识别出词语,这个该怎么来实现?
二、解决方法:
可以利用word分词的功能来实现,代码如下:
Dim sentence As String
Dim words As String
Dim WordApp As Object
If IsNull(Me.Text74) Then
MsgBox "请输入内容。", vbExclamation
Me.Text74.SetFocus
Exit Sub
End If
sentence = Me.Text74
words = ""
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Add
WordApp.Selection.TypeText Text:=sentence
WordApp.Selection.HomeKey
Do
WordApp.Selection.MoveRight Unit:=2, Count:=1, Extend:=1
If WordApp.Selection.Text = vbCr Then Exit Do
words = words & WordApp.Selection.Text & ";"
WordApp.Selection.MoveRight Unit:=1, Count:=1
Loop
WordApp.Quit SaveChanges:=0
Set WordApp = Nothing
Me.Text76 = words
End
三、演 示:
演示
标签(TAG) access数据库