本文分享:最强大脑里小度的对话功能是如何做到的?,《我的世界》电脑版防火保护指令是什么?等内容,具体看全文。
聊天中的add啥意思
最强大脑里小度的对话功能是如何做到的?
最强大脑里小度的对话功能是如何做到的?
其实我们做一个智能的聊天机器人并不容易,我这里只是实现了一个很简易的聊天机器人。 当你和这个机器人聊天的时候,每次机器人会根据你说的话的关键词找到回答的语句。如果找不到就随机的说一句默认语言。数据存储格式是xml。 以下是xml的原文件:lt?xml version1.0 encodingUTF-8?gt
ltchatgt
lt!--默认的聊天语句--gt
ltdefaultgt
ltcontentgt你在哪里?lt/contentgt
ltcontentgt你还是学生吗?lt/contentgt ......... lt/defaultgt
lt!--回答指定关键词的语句序列--gtltanswergt ltcontent key怪gt 不怪lt/contentgt
ltcontent key慢gt是啊,慢lt/contentgt
ltcontent key喂gt什么事?lt/contentgt
ltcontent key88gt再见lt/contentgt
ltcontent key谢gt没什么好谢的lt/contentgt
ltcontent key滚gt我不会滚,我会走
lt/chatgt////////////////////////////////////////////////////////////////////以下是主要的源代码:Imports System.Xml
Public Class Form1
Inherits #Region Windows 窗体设计器生成的代码 Public Sub New()
() 该调用是 Windows 窗体设计器所必需的。
InitializeComponent() 在 InitializeComponent() 调用之后添加任何初始化 End Sub 窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub Windows 窗体设计器所必需的
Private components As 注意: 以下过程是 Windows 窗体设计器所必需的
可以使用 Windows 窗体设计器修改此过程。
不要使用代码编辑器修改它。
Friend WithEvents RichTextBox1 As
Friend WithEvents TextBox1 As
Friend WithEvents Button1 As
()gt Private Sub InitializeComponent()
Dim resources As New (GetType(Form1))
New
Me.TextBox1 New
Me.Button1 New
()
RichTextBox1
New System.Drawing.Point(0, 0)
RichTextBox1
True
New (560, 304)
2
TextBox1
Me.TextBox1.Location New System.Drawing.Point(0, 312)
TextBox1
New (456, 21)
0
Me.TextBox1.Text
Button1
Me.Button1.Location New System.Drawing.Point(472, 312)
Button1
New (72, 24)
1
Me.Button1.Text Enter
Form1
New (6, 14)
New (560, 341)
(Me.Button1)
(Me.TextBox1)
()
Me.Icon CType(($this.Icon), System.Drawing.Icon)
False
Form1
Me.Text 青蛙王子
(False) End Sub#End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
readxml()
End Sub
Dim xmlFile As String ./robot.xml
Dim chatList As New ArrayList
Dim answerList As New Hashtable
Dim random As New System.Random Private Sub readxml()
Try
Dim doc As XmlDocument New XmlDocument
doc.Load(xmlFile)
Dim nodeList As XmlNodeList
Dim root As XmlElement
--默认的聊天语句--
nodeList (/chat/default/content)
Dim node As XmlNode
For Each node In nodeList
()
Next
回答指定关键词的语句序列--
nodeList (/chat/answer/content)
For Each node In nodeList
((key).Value, )
Next
Catch ex As Exception
MsgBox()
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
True
Dim Content$
If (Content ) Then
(请不要欺骗我的感情,谢谢! ControlChars.Lf)
Exit Sub
End If
If ((:) ltgt -1) Then
If learnNewWord(Content) Then
(我又学会了新的东西,谢谢! ControlChars.Lf)
End If
Exit Sub
End If
(Content ControlChars.Lf)
Dim aStr$ getSimilarContent(Content)
If (aStr Nothing) Then
Dim i% (1, )
aStr (i)
End If
( ControlChars.Lf)
()
End Sub
得到相似的字符串
Function getSimilarContent(ByVal content As String) As String
Dim keys As
Dim enumR As
While ()
Dim str$
If content.Equals(str) Then
Return answerList(str)
End If
End While
()
While ()
Dim str$
If ((str) ltgt -1) Or ((content) ltgt -1) Then
Return answerList(str)
End If
End While
Return Nothing
End Function 添加新的语句
Function learnNewWord(ByVal content As String) As Boolean
Try
Dim doc As XmlDocument New XmlDocument
Dim i% (:)
Dim str1$ (0, i)
Dim str2$ (i 1)
doc.Load(xmlFile)
Dim elem As XmlElement (content)
Dim attr As XmlAttribute (key)
str1
str2
(attr)
添加新的语句--
Dim root As XmlElement
Dim xmlNode As XmlNode (/chat/answer)
(elem)
(str1, str2)
(xmlFile)
Return True
Catch ex As Exception
MsgBox()
Return False
End Try
End Function Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As ) Handles
If () Then
Button1_Click(Nothing, Nothing)
End If
End Sub
End Class
希望您能明白!
《我的世界》电脑版防火保护指令是什么?
在聊天框里输入 /gamerule doFireTick false,即可开启火势不蔓延。
我的世界常用指令;
1、首先是/difficulty
作用:更改游戏难度(即使是在锁定的情况下)
后面跟的:easy(和平模式),hard(简单模式),normal(困难模式),peaceful(极限模式)
2、第二个是/time
作用:更改游戏时间
后面跟的:set [时间] 这里的时间是以游戏刻来计算的
add [时间] 这里的时间是指增加的时间而非设置指定时间
3、第三个是/clear
作用:清空玩家背包
后面跟的:玩家名字即可
4、第四个是/effect
作用:给个BUFF
后面跟的:玩家名 药水id 秒数 药水等级
药水id列表:中毒 ID 【19】
速度 ID 【1】
虚弱 ID 【18】
饥饿 ID 【17】
失明 ID 【15】
夜视 ID【16】
隐身 ID 【14】
水下呼吸 ID 【13】
缓慢 ID 【2】
急迫 ID 【3】
挖掘疲劳 ID【4】
力量 ID 【5】
瞬间治疗 ID 【6】
瞬间伤害 ID 【7】
跳跃提升 ID 【8】
反胃 ID【9】
生命恢复 ID 【10】
抗性提升 ID 【11】
防火 ID 【12】
5、第五个是/gamemode
作用:更改游戏模式
后面跟的:0,1,2,3
0是生存模式,1是创造模式,2是冒险模式,3是观察者模式
6、第六个是/fill
作用:如同这个词的翻译一样用于填充方块
我的推荐使用方法是后3个波浪号不动那么开始点会在你的脚下
前三个分别是X轴Y轴Z轴去更改他们就行了

117笔记