| |
Posted: Apr 11, 2011 |
[ # 46 ]
|
|




Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
New version up… supports ^import and ^export of facts.
|
|
|
|
|
| |
Posted: Apr 11, 2011 |
[ # 47 ]
|
|




Administrator
Total posts: 3111
Joined: Jun 14, 2010
|
Thanks, Bruce! I’ll check it out. 
|
|
|
|
|
| |
Posted: Apr 11, 2011 |
[ # 48 ]
|
|


Experienced member
Total posts: 43
Joined: Mar 29, 2011
|
Hi Bruce,
I have two small suggestions that can make the language easier to program and understand:
a. Inside patterns, you use brackets [] for choice and parens () for sequence. To be consistent, I think you should use brackets for topic keywords and concept keywords instead of parens, because the semantics there is of a choice.
b. In “if” conditions, you use == for comparison. To be consistent, I think you should also use == for comparing variables inside patters, instead of a single =.
|
|
|
|
|
| |
Posted: Apr 12, 2011 |
[ # 49 ]
|
|


Experienced member
Total posts: 43
Joined: Mar 29, 2011
|
ן would like to create a web interface to Chat Script, so that developers can upload their bots and immediately chat with them using a browser.
To do this, I need a way to build a bot from the command line. Is this possible?
|
|
|
|
|
| |
Posted: Apr 12, 2011 |
[ # 50 ]
|
|


Experienced member
Total posts: 43
Joined: Mar 29, 2011
|
I am trying to write a Java client to the ChatScript server, for use in a larger project. Here is what I have so far:
public class ChatScriptClient { public ChatScriptClient(String host, int port, String username, String botname) { this.host=host; this.port=port; this.username=username; this.botname=botname; }
public String sayAndListen(String text) throws IOException { socket = new Socket(host, port); say(text); return listen(); }
private String host; private int port; private String username; private String botname; private Socket socket = null; private byte[] buffer = new byte[1000]; private void say(String text) throws IOException { System.out.println(username+": "+text); String message = username+"\0"+botname+"\0"+text+"\0"; OutputStream outputStream = socket.getOutputStream(); outputStream.write(message.getBytes()); outputStream.flush(); System.out.println(" Sent data"); } private String listen() throws IOException { String reply; InputStream inputStream = socket.getInputStream(); int count = inputStream.read(buffer); System.out.println(" Received "+count+" data"); reply = (count<=0? null: new String(buffer,0,count)); inputStream.close(); return reply; }
/** * main program for testing only */ public static void main(String[] args) throws IOException { ChatScriptClient client = new ChatScriptClient("localhost", 1024, "h",""); System.out.println(client.sayAndListen(":ping")); // Make sure the server can hear you. If all is OK, you should see "Unknown command" on the server console System.out.println(client.sayAndListen("hello!")); } }
It seems to work, but sometimes it hangs for a long time, and then returns a sentence such as “Sorry, I had to answer the phone”, or “Sorry, I got distracted. What did you say?”. These sentences probably mean something, maybe a timeout, but I don’t know what exactly.
|
|
|
|
|
| |
Posted: Apr 18, 2011 |
[ # 51 ]
|
|




Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
1. The sorry… is a timeout of the http client thread when the main engine fails to respond within sufficient time.
WHY you are timing out is another matter entirely.
2. I don’t know what you mean by build a bot from the command line. I guess you mean developers upload both the actual files and the files.txt file. one can issue build commands on the command line. one could do
chatscript build0=filepath and then chatscript build1=filepath, for example.
3. I understand your desire for [] for concept and topic. I could argue that “declaration of a set” is not the same thing as the action behavior of a choice, but I see your point that they “are” the choices. I’m not sure whether or not its worth changing at this point. Any one else want to comment?
4. I could probably change IF conditions to allow single character relations and avoid any syntax confusion with assignment. I was trying to keep with C-style notation, and 2 character notation so that != and == would be the same. I probably COULD
change IF relations to allow if (a = b) but I’m not sure again whether its worth changing at this point.
|
|
|
|
|
| |
Posted: Apr 18, 2011 |
[ # 52 ]
|
|




Administrator
Total posts: 3111
Joined: Jun 14, 2010
|
Most of the programming/scripting languages I’m familiar with use == as an equality operator, and = as an assignment. the only exception to this (in my experience, which is by no means comprehensive) is Visual Basic. I’m good either way, but for the sake of consistency, if == is used in one part of ChatScript to test equality, then perhaps it should be used throughout. Just my two cents worth. 
By the way, Bruce; are you keeping a changelog for ChatScript anywhere? if so, I wouldn’t mind having a look at it.
|
|
|
|
|
| |
Posted: Apr 18, 2011 |
[ # 53 ]
|
|




Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
The change log is changes.txt which is a top level file in the sourceforge project.. (new version just released).
|
|
|
|
|
| |
Posted: Apr 18, 2011 |
[ # 54 ]
|
|




Administrator
Total posts: 3111
Joined: Jun 14, 2010
|
Oops? I miscommunicated my intention there. I already knew about changes.txt. What I meant was do you have a changelog posted to a website, or other publicly accessible location? It’s sometimes nice to see what’s been changed prior to downloading the new version. 
|
|
|
|
|
| |
Posted: Apr 18, 2011 |
[ # 55 ]
|
|




Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
I dont have a webpage devoted to listing it… but you can ALWAYS just download changes.txt from sourceforge by itself and that is a publically accessible location 
|
|
|
|
|
| |
Posted: Apr 19, 2011 |
[ # 56 ]
|
|




Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
next release of chatscript will
1: I understand your desire for [] for concept and topic. ChatScript will now accept () or [] and the docs will use only [].
2. Also, pattern compares will allow 2character values, like ==, and the docs will not refer to the fact that they will also accept the single = as well.
|
|
|
|
|
| |
Posted: Apr 27, 2011 |
[ # 57 ]
|
|


Experienced member
Total posts: 43
Joined: Mar 29, 2011
|
“The sorry… is a timeout of the http client thread when the main engine fails to respond within sufficient time” - Can you please elaborate?
I didn’t use a client, I started LinuxChatScript at server mode.
When I sent the string “:ping” to the server, I saw on the server console “Unknown command”, which makes sense because there is no command “ping”. However, the client sometimes received an immediate (empty) response, while other times it recieved the timeout response.
My computer is very lightly loaded so this is probably not the problem. Do you have any idea what it can be?
|
|
|
|
|
| |
Posted: Apr 27, 2011 |
[ # 58 ]
|
|




Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
I’m a bit confused…. You say you ran LinuxChatScript as a server. That implies that to communicate with it once it starts, you would have to have a client send a message to its port. If so, then the “sorry…” is a timeout message sent back when the engine fails to generate a response within an alloted time.
Also, you say you sent the string :ping to the server. This again implies to me you “used a client” to talk to the server. As all input that starts with colon is considered a command, if it cannot find that command (and :ping is not a command) then it would certainly say at the console “unknown command”. I’m not certain without checking what if anything is sent back to a client given an unknown command is given… but let’s start with the basics… If you send from a client some normal text, what happens? Does it get back some response?
|
|
|
|
|
| |
Posted: Apr 27, 2011 |
[ # 59 ]
|
|


Experienced member
Total posts: 43
Joined: Mar 29, 2011
|
I used a very simple client - the Java program listed above is the entire client I used. As you can see it doesn’t contain any of the “sorry…” messages, so I wonder where they could come from?
“If you send from a client some normal text, what happens?” - sometimes (about 50% of the times) it gets back with the correct response, but other times it gets back with the timeout response. I couldn’t find any regularity.
|
|
|
|
|
| |
Posted: Apr 28, 2011 |
[ # 60 ]
|
|




Moderator
Total posts: 2372
Joined: Jan 12, 2010
|
On the java program above to talk to the engine…..
It talks to the engine PRESUMING a conversation is in progress. One should first “start” a conversation by sending a message of “”. Starting a conversation creates the initial user’s existence. If you FAIL to do this…. things might not work.
bruce
|
|
|
|
|