📄 nlp.frm
字号:
VERSION 5.00
Begin VB.Form nlm
BorderStyle = 1 'Fixed Single
Caption = "CoLIN 人工语言模拟"
ClientHeight = 4485
ClientLeft = 4200
ClientTop = 4200
ClientWidth = 8925
Icon = "nlp.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 4485
ScaleWidth = 8925
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox Computer
Appearance = 0 'Flat
ForeColor = &H00FF0000&
Height = 3255
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 3
Text = "nlp.frx":014A
Top = 480
Width = 8655
End
Begin VB.TextBox Human
Appearance = 0 'Flat
Height = 315
Left = 120
TabIndex = 2
Top = 3960
Width = 7215
End
Begin VB.CheckBox issatisfied
Caption = "关闭学习功能"
Height = 495
Left = 7440
TabIndex = 1
Top = 0
Value = 1 'Checked
Width = 2055
End
Begin VB.Data datWords
Caption = "Data1"
Connect = "Access"
DatabaseName = "App.Path & ""\nlp.mdb"""
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 465
Left = 3240
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "Words"
Top = 0
Visible = 0 'False
Width = 1620
End
Begin VB.CommandButton Talk
Appearance = 0 'Flat
BackColor = &H0000FF00&
Caption = "发送"
Default = -1 'True
Height = 375
Left = 7440
TabIndex = 0
Top = 3960
Width = 1335
End
Begin VB.Label Label2
BackColor = &H8000000A&
Caption = "交谈记录"
Height = 255
Left = 120
TabIndex = 4
Top = 120
Width = 1455
End
Begin VB.Menu mnuFile
Caption = "文件"
Begin VB.Menu mnuClear
Caption = "清除数据库"
End
Begin VB.Menu mnucap1
Caption = "-"
End
Begin VB.Menu mnuClose
Caption = "退出"
End
End
Begin VB.Menu mnuEdit
Caption = "编辑"
Begin VB.Menu mnuCcomp
Caption = "复制谈话记录"
End
Begin VB.Menu mnuPaste
Caption = "粘贴"
End
End
Begin VB.Menu mnuhelp
Caption = "帮助"
Begin VB.Menu mnuAbout
Caption = "帮助"
End
End
End
Attribute VB_Name = "nlm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function ShellExecute Lib _
"shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Activate()
Human.SetFocus
End Sub
Private Sub Form_Load()
datWords.DatabaseName = App.Path & "\nlp.mdb"
datWords.Refresh
End Sub
Public Sub cinWeb(htmlfile, Optional dr)
If IsMissing(dr) Then
dr = "C:\"
End If
Dim iret As Long
iret = ShellExecute(Me.hwnd, _
vbNullString, _
htmlfile, _
vbNullString, _
dr, _
SW_SHOWNORMAL)
End Sub
Private Sub mnuAbout_Click()
frmAbout.Show
End Sub
Private Sub mnuCcomp_Click()
Clipboard.SetText Computer, 1
End Sub
Private Sub mnuClear_Click()
Set dbs = OpenDatabase(App.Path & "\nlp.mdb")
If MsgBox("你确定这样做吗?", 276, "删除所有数据!") = vbNo Then Exit Sub
If MsgBox("数据将不可恢复!", 257, "确定删除?") = vbCancel Then Exit Sub
dbs.Execute "delete * from words"
datWords.Refresh
Computer = ""
Human = ""
End Sub
Private Sub mnuClose_Click()
Unload Me
End Sub
Private Sub mnuPaste_Click()
Human = Clipboard.GetText
End Sub
Private Sub Talk_Click()
Dim words(100) As String
Dim a As Long
On Error Resume Next
If Human <> "" Then
Computer = Chr(13) & Chr(10) & "你:" & Human & Chr(13) & Chr(10) & Computer
End If
Human = LCase(Trim(Human))
Human = " " & Human & " "
Start = 1
cword = 1
For a = 1 To Len(Human)
If Mid(Human, a, 1) = " " And a > 1 Then
words(cword) = Mid(Human, Start + 1, a - Start)
If Len(words(cword)) > Len(maxword) Then maxword = Trim(words(cword))
Start = a
cword = cword + 1
End If
Next a
If issatisfied.Value = 0 Then
For a = 1 To cword - 1
If Trim(words(a)) <> "" Then
middle = Trim(words(a))
datWords.Recordset.FindFirst ("middle = '" & Trim(words(a)) & "' and previous = '" & Trim(words(a - 1)) & "' and next = '" & Trim(words(a + 1)) & "'")
If datWords.Recordset.NoMatch = True Then
datWords.Recordset.AddNew
datWords.Recordset.Fields(0) = middle
datWords.Recordset.Fields(1) = words(a - 1)
datWords.Recordset.Fields(2) = words(a + 1)
datWords.Recordset.Update
End If
End If
Next a
End If
Human = ""
maxword = words(Int(Rnd * (cword - 1)) + 1)
temp = maxword
wrd = choose(maxword, False)
Do While wrd <> ""
temp = wrd & " " & temp
wrd = choose(wrd, False)
Loop
wrd = choose(maxword, True)
Do While wrd <> ""
temp = temp & " " & wrd
wrd = choose(wrd, True)
Loop
If Trim(temp) <> "" Then
Computer = "CoLIN:" & temp & Computer
End If
Human = ""
Human.SetFocus
End Sub
Public Function choose(word, forward As Boolean)
Set dbs = OpenDatabase(App.Path & "\nlp.mdb")
Set tdf = dbs.OpenRecordset("select * from words where middle = '" & word & "'")
tdf.AbsolutePosition = Int(Rnd * (tdf.RecordCount)) + 1
choose = IIf(forward = True, tdf!Next, tdf!previous)
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -