forked from oren/eliza-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
236 lines (202 loc) · 11.1 KB
/
index.html
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<HTML>
<HEAD>
<TITLE>Eliza (elizabot.js)</TITLE>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="elizabot.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="elizadata.js"></SCRIPT>
<link rel="stylesheet" type="text/css" href="style.css">
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
var eliza = new ElizaBot();
var elizaLines = new Array();
var displayCols = 70;
var displayRows = 20;
function elizaReset() {
eliza.reset();
elizaLines.length = 0;
elizaStep();
}
function elizaStep() {
var f = document.forms.e_form;
var userinput = f.e_input.value;
if (eliza.quit) {
f.e_input.value = '';
if (confirm("This session is over.\nStart over?")) elizaReset();
f.e_input.focus();
return;
}
else if (userinput != '') {
var usr = 'YOU > ' + userinput;
var rpl ='ELIZA > ' + eliza.transform(userinput);
elizaLines.push(usr);
elizaLines.push(rpl);
// display nicely
// (fit to textarea with last line free - reserved for extra line caused by word wrap)
var temp = new Array();
var l = 0;
for (var i=elizaLines.length-1; i>=0; i--) {
l += 1 + Math.floor(elizaLines[i].length/displayCols);
if (l >= displayRows) break
else temp.push(elizaLines[i]);
}
elizaLines = temp.reverse();
f.e_display.value = elizaLines.join('\n');
}
else if (elizaLines.length == 0) {
// no input and no saved lines -> output initial
var initial = eliza.getInitial();
elizaLines.push(initial);
f.e_display.value = initial + '\n';
}
f.e_input.value = '';
f.e_input.focus();
}
</SCRIPT>
</HEAD>
<BODY TOPMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" BOTTOMMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" STYLE="border:0" onload="window.setTimeout('elizaReset()',100)"><A NAME="top"></A>
<CENTER>
<P> </P>
<TABLE BORDER="0" CELLSPACING="10" CELLPADDING="0">
<FORM NAME="e_form" onsubmit="elizaStep();return false">
<TR><TD COLSPAN="2"><TEXTAREA NAME="e_display" COLS="70" ROWS="20"></TEXTAREA></TD></TR>
<TR VALIGN="middle">
<TD><INPUT TYPE="text" NAME="e_input" SIZE="50"></TD>
<TD ALIGN="right"><INPUT TYPE="submit" VALUE=" Talk "> <INPUT TYPE="reset" VALUE="Reset" onClick="window.setTimeout('elizaReset()',100)"></TD>
</TR>
</FORM>
</TABLE>
</CENTER>
<P> </P>
<!--<P ALIGN="center">For a comfortable terminal-like interface see the <A HREF="http://www.masswerk.at/elizabot/eliza.html">ELIZA-Terminal</A>.</P>
<P> </P>-->
<TABLE BORDER="0" CELLSPACING="12" CELLPADDDING="0">
<TR><TD COLSPAN="2">
ELIZA è un Chatterbot scritto nel 1966 da Joseph Weizenbaum che fa la parodia di un terapeuta Rogersiano, in buona parte rispondendo al paziente con domande ottenute dalla riformulazione delle affermazioni del paziente stesso. Così, per esempio, alla frase "Mi fa male la testa" il programma può ribattere con "Perché dici che ti fa male la testa?" oppure la risposta a "Mia madre mi odia" potrebbe essere "Chi altro nella tua famiglia ti odia?"
<BLOCKQUOTE>
At this writing, the only serious ELIZA scripts which exist are some which cause
ELIZA to respond roughly as would certain psychotherapists (Rogerians). ELIZA
performs best when its human correspondent is initially instructed to
"talk" to it, via the typewriter of course, just as one would to a
psychiatrist. This mode of conversation was chosen because the psychiatric
interview is one of the few examples of categorized dyadic natural language
communication in which one of the participating pair is free to assume the pose
of knowing almost nothing of the real world. If, for example, one were to tell a
psychiatrist "I went for a long boat ride" and he responded "Tell
me about boats", one would not assume that he knew nothing about boats, but
that he had some purpose in so directing the subsequent conversation. It is
important to note that this assumption is one made by the speaker. Whether it is
realistic or not is an altogether separate question. In any case, it has a
crucial psychological utility in that it serves the speaker to maintain his
sense of being heard and understood. The speaker furher defends his impression
(which even in real life may be illusory) by attributing to his conversational
partner all sorts of background knowledge, insights and reasoning ability. But
again, these are the <em>speaker's</em> contribution to the conversation.
</BLOCKQUOTE>
Per la conversazione di esempio di Joseph Weizenbaum citata nel suo articolo vai sulla pagina <A HREF="eliza_test.html">Eliza Test</A>.
</TD></TR>
<TR><TD COLSPAN="2"> </TD></TR>
<TR><TD COLSPAN="2">
<H3>About elizabot.js</H3>
<P>"elizabot.js" is an object oriented JavaScript library for [multiple] instances of the Eliza program.</P>
<PRE STYLE="line-height: 120%;">Synopsis:
new ElizaBot( <I><random-choice-disable-flag></I> )
ElizaBot.prototype.transform( <I><inputstring></I> )
ElizaBot.prototype.getInitial()
ElizaBot.prototype.getFinal()
ElizaBot.prototype.reset()
Usage:
var eliza = new ElizaBot();
var initial = eliza.getInitial();
var reply = eliza.transform(inputstring);
if (eliza.quit) {
<SPAN STYLE="color: #303030">// last user input was a quit phrase</SPAN>
}
<SPAN STYLE="color: #303030">// method `transform()' returns a final phrase in case of a quit phrase
// but you can also get a final phrase with:</SPAN>
var final = eliza.getFinal();
<SPAN STYLE="color: #303030">// other methods: reset memory and internal state</SPAN>
eliza.reset();
<SPAN STYLE="color: #303030">// to set the internal memory size override property `memSize':</SPAN>
eliza.memSize = 100; <SPAN STYLE="color: #303030">// (default: 20)</SPAN>
<SPAN STYLE="color: #303030">// to reproduce the example conversation given by J. Weizenbaum
// initialize with the optional random-choice-disable flag</SPAN>
var originalEliza = new ElizaBot(true);
</PRE>
<P>As ElizaBot is a totally self-contained object and instances use their own internal memory it's possible to have multiple instances of the ElizaBot object talking to each other.</P>
<P>ElizaBot is also a general chatbot engine that can be supplied with any rule set.</P>
<PRE STYLE="line-height: 120%;">
Data Structures (cf: "elizadata.js"):
elizaInitials ......... Array of initial phrases
elizaFinals .......... Array of final phrases
elizaQuits ............ Array of quit phrases
elizaPres ............. Array of alternating name value pairs for preprocessing
elizaPosts ............ Array of alternating name value pairs for postprocessing
elizaSynons ........... Object of words and their synonyms (as array)
elizaPostTransforms ... regexp/replacement pairs to be performed as final cleanings
elizaKeywords ......... Array of keywords with decompositions and reasemblies
elizaKeywords elements are of:
["<key>", <rank>,
[
[ <SPAN STYLE="color: #303030">// first decomposition pattern</SPAN>
"<decomp>",
["<reasmb>", "<reasmb>", "<reasmb>"]
],
[ <SPAN STYLE="color: #303030">// second decomposition pattern</SPAN>
"<decomp>",
["<reasmb>", "<reasmb>", "<reasmb>"]
]
]
]
keywords with higher rank take precedence.
decompositions are matched in definition order.
reasemblies are chosen by random or cycled through if the no-random flag ist set.
the special keyword "xnone" holds the rules for default phrases (no match).
decomposition and reasembly syntax follow the "canonical" form:
decomposition:
* ... any words (incl. none)
$ ... (in first position) reassemble for memory only
@synon ... substitute entry with synononym expression
reassembly:
(n) ... insert param of position n (first is "1")
positions are any matchings of "*" or "@synon"
pres, posts, synonyms, keywords, decompositions all in lower case.
all definitions are optional but at least elizaKeywords should be supplied.
if no keywords are found `transform()' returns the default string:
"I am at a loss for words.".
Note: "elizaPostTransforms" is not a standard ELIZA feature and was included to provide
a smoothing mechanism for any productions of a bot-to-bot conversation.
</PRE>
<P>Data representations and syntax follow the "canonical" form.<BR>
(Since all data is transformed to and matched as regular expressions, you could also use regexps in the keywords and decompositions. Do not use any "*" expressions in decomposition patterns as "*" will be transformed to a regexp-pattern itself.)<BR>
The structure of "elizaKeywords" follows the internal data model as described by J. Weizenbaum in his article.</P>
<P> <BR>
"elizabot.js" by © Norbert Landsteiner 2005;<BR>
mass:werk – media environments <<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>>.<br>
translated in italian by © cttynul 2020;</P>
<P>Distribution:<BR>
"elizabot.js" is free software and provided "as is".
It 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.</P>
<P>Compatibility:<BR>
"elizabot.js" should be compatible to most browsers with support of RegExp (that is all standard browsers).<BR>
(Version 1.1 doesn't require the support of lambda functions in RegExps any more.)</P>
</TD></TR>
<TR><TD COLSPAN="2"> </TD></TR>
<TR><TD COLSPAN="2"><B>Download</B>: <A HREF="https://github.com/cttynul/eliza/archive/master.zip">eliza.zip</A> <SMALL>(ZIP file, 15 KB incl. documentation)</SMALL></TD></TR>
<TR><TD COLSPAN="2"> </TD></TR>
<TR><TD COLSPAN="2">References:</TD></TR>
<TR VALIGN="top">
<TD>
Weizenbaum, Joseph "ELIZA – A Computer Program For the Study of Natural Language
Communication Between Man and Machine"<BR>
in: Communications of the ACM; Volume 9 , Issue 1 (January 1966): p 36-45.
</TD>
</TR>
<TR><TD COLSPAN="2"> </TD></TR>
<TR><TD COLSPAN="2"><SMALL>> <A HREF="#top">top of page</A></SMALL></TD></TR>
<TR><TD COLSPAN="2"> </TD></TR>
<TR><TD COLSPAN="2" STYLE="font-family: arial,helvetica,sans-serif; font-size: 12px;">N. Landsteiner 2005; <<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>></SMALL></TD></TR>
<TR><TD COLSPAN="2" STYLE="font-family: arial,helvetica,sans-serif; font-size: 12px;">cttynul 2020; <<A HREF="https://cttynul.github.io/" TARGET="_blank">https://cttynul.github.io</A>></SMALL></TD></TR>
<TR><TD COLSPAN="2"> </TD></TR>
</TABLE>
</BODY>
</HTML>