AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Where is the main function of ChatScript program?
 
 

Hi
I want to know, if I like to get inputs from other programs(like a text file, or other program) instead of directly typing by user, how can I do that?

Also if I want to write the answers in the file, instead of showing it to user in terminal, where can I do this?

 

 
  [ # 1 ]

Or maybe it’s better to ask:

How can I write a program that inside it, I can call ChatScript program, pass my input file to it and get the results as an output text file?

Are there any example for this? I mean something like this:

#include <stdio.h>
#include <chatScript.h> //for example!

int main()
{
FILE * output;
ChatScript( fopen("input.txt", "r"));
ChatScript_write("output.txt","w"));
return 0;
}

 

 

 
  [ # 2 ]

This is more clear what I am seeking for:


#include <fstream>
#include <iostream>
#include <string>
#include <chatScript.h> //for example!
using namespace std;

int main()
{
ofstream output;
string str1, str2;
getline(cin, str1);

str2= ChatScript_input(str1); //this is ChatScript function that i am looking for!

output.open("output.txt");
output<< "str2";
output.close();

return 0;
}

 

 
  [ # 3 ]

I think this is what you are looking for:
https://github.com/bwilcox-1234/ChatScript/blob/master/WIKI/CLIENTS-AND-SERVERS/ChatScript-External-Communications.md

Read the chapter “Embedding ChatScript within another program”

 

 
  [ # 4 ]
Tobias La - Oct 4, 2017:

I think this is what you are looking for:
https://github.com/bwilcox-1234/ChatScript/blob/master/WIKI/CLIENTS-AND-SERVERS/ChatScript-External-Communications.md

Read the chapter “Embedding ChatScript within another program”

Thank you very much Tobias!
I read the chapter, as I understood, I must use these two functions in my program to use CS externally:

InitSystem(int argc, char * argv[],char* unchangedPath, char* readablePath, char* writeablePath, USERFILESYSTEM* userfiles)

int PerformChat(char* user, char* usee, char* incoming,char* ip,char* output);

But, before that, I didn’t understand STEP1 about compilation! How should I compile system?
I only should ” // #define NOMAIN 1” line and compile the ChatScript again?
Or should I create my own program and copy all the .cpp file inside ChatScript/SRC folder to a new folder that my main.cpp program is inside, and compile them again? but how?

Sorry but I am newbie and need more explanation :(

 

 
  [ # 5 ]

I tried to compile with “make server” command in the SRC file but I got this error:

m@m-N552VW:~/Downloads/ChatScript-7.55/SRC$ make server
************ LINUX VERSION ************
g++ -c -std=c++11 -Wall -funsigned-char -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 -DDISCARDPOSTGRES=1 -DDISCARDMONGO=1 -DDISCARDMYSQL=1 -Ievserver evserver.cpp -o evserver.o
evserver.cpp: In function ‘int settcpnodelay(int)’:
evserver.cpp:263:40: error: ‘TCP_NODELAY’ was not declared in this scope
    return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*) &on;, sizeof(on));
                          ^
Makefile:110: recipe for target ‘evserver.o’ failed
make: *** [evserver.o] Error 1

 

 
  [ # 6 ]
reza electronics - Oct 5, 2017:
Tobias La - Oct 4, 2017:

I think this is what you are looking for:
https://github.com/bwilcox-1234/ChatScript/blob/master/WIKI/CLIENTS-AND-SERVERS/ChatScript-External-Communications.md

Read the chapter “Embedding ChatScript within another program”


Or should I create my own program and copy all the .cpp file inside ChatScript/SRC folder to a new folder that my main.cpp program is inside, and compile them again?

Yes, that is how I did it. Maybe there is a way to compile it as a library.

You add it like every other source files you want to add to your project. depends on your build envirement.

 

 
  [ # 7 ]

In a previous employment I built CS as a Windows DLL that I could then load into the program I was using. That was a pretty simple process of just changing the target type and defining NOMAIN.

I don’t have the experience of doing that on Linux, but it is probably pretty similar.

 

 
  [ # 8 ]
Tobias La - Oct 5, 2017:
reza electronics - Oct 5, 2017:
Tobias La - Oct 4, 2017:

I think this is what you are looking for:
https://github.com/bwilcox-1234/ChatScript/blob/master/WIKI/CLIENTS-AND-SERVERS/ChatScript-External-Communications.md

Read the chapter “Embedding ChatScript within another program”


Or should I create my own program and copy all the .cpp file inside ChatScript/SRC folder to a new folder that my main.cpp program is inside, and compile them again?

Yes, that is how I did it. Maybe there is a way to compile it as a library.

You add it like every other source files you want to add to your project. depends on your build envirement.


You mean I must copy all the files in the picture inside the folder of my program beside my main.cpp?
What about the folders (curl, ductapi, easywclient, evserver, include, mongo, mysql, postgres)? Should I copy these folders too?
And another question is, I must include which one in my main.cpp ? Should I include only “common.h” ?

http://uupload.ir/files/vdqt_jjj.png

 

 
  [ # 9 ]

Where is forums admin? I need help as I said here :

I tried to compile with “make server” command in the SRC file but I got this error:

m@m-N552VW:~/Downloads/ChatScript-7.55/SRC$ make server
************ LINUX VERSION ************
g++ -c -std=c++11 -Wall -funsigned-char -Wno-write-strings -Wno-char-subscripts -Wno-strict-aliasing -DLOCKUSERFILE=1 -DEVSERVER=1 -DEVSERVER_FORK=1 -DDISCARDPOSTGRES=1 -DDISCARDMONGO=1 -DDISCARDMYSQL=1 -Ievserver evserver.cpp -o evserver.o
evserver.cpp: In function ‘int settcpnodelay(int)’:
evserver.cpp:263:40: error: ‘TCP_NODELAY’ was not declared in this scope
  return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*) &on;, sizeof(on));
                  ^
Makefile:110: recipe for target ‘evserver.o’ failed
make: *** [evserver.o] Error 1

 

 
  [ # 10 ]

Why do you need a forum admin? I have little to no experience with ChatScript or any flavor of C, and I can’t coerce anyone to answer you. We’re ALL volunteers here, after all.

Just be patient is my advice. Our community is filled with people who love to help out, but we don’t always have the time we would like to spend on questions here, and we’re not gods, so may not have the answers you seek. It’s also worth pointing out that this community (like God) helps those who help themselves, so if you’re stuck, it may be beneficial to you to to let us know what you tried to do on your own to fix the issue. Not only does this show us that you’ve made an honest effort to take care of the problem on your own, it also narrows the list of possible solutions, making the likelihood of finding a solution that much greater. Something to think about, yes? smile

Something that you might find helpful is reading http://www.catb.org/~esr/faqs/smart-questions.html - The information there, while presented in a snarky, almost belligerent fashion, is terrific with respect to the information that it provides. This won’t help you directly with your problem with ChatScript, but it will likely help you to know how to get the help you need, now and in the future.

 

 
  [ # 11 ]

Hello Dave,
Sorry about seeking you smile I thought the admin of this forum is the author of ChatScript.  Also I should do my project soon and haven’t huge time to read all the manuals. So I asked here. But you right. This is OpenSource world and we should not desire commercial support!

 

 
  [ # 12 ]

I should point out that most people successfully compile in linux and I am not a linux specialist. But it would appear that something in your linux world is wrong given that a standard word like TCP_NODELAY is not defined. That is not from CS itself, that is from stuff it includes.

 

 
  [ # 13 ]
Bruce Wilcox - Oct 7, 2017:

I should point out that most people successfully compile in linux and I am not a linux specialist. But it would appear that something in your linux world is wrong given that a standard word like TCP_NODELAY is not defined. That is not from CS itself, that is from stuff it includes.

Thank you Bruce,
I have a question. If I want to use ChatScript locally should I use “make server” command to compile it?

My goal is using ChatScript upon RaspberryPi board without internet access. Also it should be by inner calling within other main program externally, not directly in terminal by user.

 

 
  [ # 14 ]

make server will build a linux stand-alone AND server version. 

When you run CS on linux, it defaults to server mode but can be configured local via ./ChatScript local.
When you run CS on windows, it defaults to local mode but can be configured server via ChatScript port=xxxx

 

 
  [ # 15 ]

I solved the problem by adding ” #include <netinet/tcp.h> ” in above of ” evserver.cpp ” file, but new problem occurred :

Makefile:110: recipe for target ‘textUtilities.o’ failed
make: *** [textUtilities.o] Error 1

 

 1 2 > 
1 of 2
 
  login or register to react