This repository was archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBot.cs
More file actions
83 lines (66 loc) · 3.12 KB
/
Bot.cs
File metadata and controls
83 lines (66 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/****************************************************************************
AimlBot - a library for building all manner of AIML based chat bots for
the .NET platform.
Copyright (C) 2008 Nicholas H.Tollervey (http://ntoll.org)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
To contact the author directly use the contact information found here:
http://ntoll.org/about
A full copy of the GNU Affero General Public License can be found in the
License.txt file in the Docs folder in the root of this project.
For a commercial license please contact the author.
****************************************************************************/
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
[assembly:CLSCompliant(true)]
namespace AimlBot
{
/// <summary>
/// Encapsulates an instance of a conversational agent (bot)
/// </summary>
public class Bot
{
#region Member variables
/// <summary>
/// A graph of nodes for the finite state automata used when pattern matching for substitutions.
/// </summary>
public Normalize.Utils.FsaNode FsaGraph;
/// <summary>
/// The tokens used by this bot to define the end of a sentence.
/// </summary>
public char[] SentenceSplittingTokens;
/// <summary>
/// The tokens (if any) used by this bot to define the border between words
/// </summary>
public char[] WordSplittingTokens;
/// <summary>
/// This regex defines what characters to replace with " " when doing a pattern fit normalization
/// </summary>
public Regex PatternFitExclusions;
#endregion
#region Utility methods
/// <summary>
/// Given a dictionary of substitutions creates a new graph of nodes for the finite state
/// automata used when pattern matching for substitutions.
/// </summary>
/// <param name="substitutions">The dictionary of substitutions where the key is the search item and the value is what to replace it with.</param>
public void CreateSubstitutionGraph(Dictionary<string, string> substitutions)
{
this.FsaGraph = new AimlBot.Normalize.Utils.FsaNode(0);
foreach (string key in substitutions.Keys)
{
this.FsaGraph.Add(key, substitutions[key]);
}
}
#endregion
}
}