I have a web page where I just play with HTML, CSS and Javascript.
I have decided to create a Chat Bot there.
AIML seems like the way to go, and I already know how to write it.
Question is: After I have my bot.aiml file, what do I do with it?
I assume I need some sort of javascript function to interact with it.
If you only have access to HTML, CSS and JavaScript and not to some server-side technology, then you will need a JavaScript AIML interpreter.
A quick search turns up the following:
AIML Interpreter written in node.js
AIMLInterpreter is a module that allows you to parse AIML files and to find the correct answer to a given message.
aiml-high written in node.js. Built on aimlinterpreter.
aiml-high is a module that allows you to parse AIML files and to find the correct answer to a given message.
Surly2
a half-complete node.js AIML interpreter with a bad attitude.
Surly2 is a remake from the ground up of Surly using Node 5 and using as much asynchronicity as possible.
burly
Burly is a fork of Surly2
I too searched for the same but sadly i was not successful of creating my own bot..instead i found a website which will do exactly the same instead of we reinventing the cycle...
Create your account over here
http://www.pandorabots.com/botmaster/en/new-account
After signing in you have option of uploading your own AIML file and use the deafult AIML files and also Custom HTML and much more....
ChatterBean can help you to interpret the AIML files. From Alicebot.org,
ChatterBean is an AIML interpreter (also known as "Alicebot") written in pure Java.
For integration with Web, host a J2EE application with ChatterBean.
Since you already have understanding of chatbot, you can integrate it to your webpage by using php or j2ee (jsp being the easiest) which would send a request to the bot methods and return response.
Related
I am an Android developer and I am new to java web development, so please apologize if my thought is wrong. In our web app project we have to compare images (GIF/PNG/JPEG) and have to show the result.
We got a javascript lib (Resemble.js) which will compare the images and will give the result.
Please help on implementing this lib to my web app project. As its a js lib we can implement it only in front end right? If so is this a correct way? Because we have all other process in backend. Or else how to use a js lib in backend
Or let me know the best way in implementing the same. We are using React.js for front-end.
To execute javascript you need a javascript engine. A java virtual machine is not designed to run javascript so short answer is: You should use the Resemble.js into your front-end browser's engine (or into a back-end server that process javascript like Node.js).
Long answer: There are implementation of JavaScript written in Java that you could use (I don't konw if supports HTML). Take a look at: How can I run JavaScript code at server side Java code?
I have a friend who started learning website development and he's into php now. I, on the other side started studying Javascript. He asked me if it's possible to use JS instead of php code entirely?
Well, I started learning JS because someone told me, it can be used for both frontend, backend (via NodeJS) and the database (via MongoDB). Though, since I' m a beginner in this field, I'm not sure in the answer, and I'm interested anyway, so I ask you: is it possible?
He asked me if it's possible to use JS instead of php code entirely?
Yes, it's entirely possible. There are several server-side JavaScript options. Probably the most well-known is NodeJS (usually, but not necessarily, plus Express). But Microsoft has always supported JScript (their dialect of JavaScript) in classic ASP, you can use JavaScript in the Java JVM (via Rhino or Nashorn) and thus use JavaScript in servlets, for years there was SilkJS (built on Google's V8) and now there's its successor DecafJS (built on the JVM), etc.
I'm trying to execute JavaScript in a C# program, and I'm trying to determine:
Would it be better to create a state machine for JavaScript, or should it be compiled into MSIL before executing it?
I'm really looking for techniques rather than solutions. Some attempt to compile the JavaScript, there by treating it as a programming language, others use a state machine and treat it as it was meant to be : a scripting language.
Any documentation on the methods used for executing is welcome also.
The easiest way to run JS in a C# program is to use one of the existing .Net JS runtimes: IronJS, Jurassic, and Jint. If you're interested in adding another .Net-based interpreter to the mix, examining their code is where I'd start; If you're embedding JS in your program then using a preexisting one is probably the way to go.
You haven't explained your scenario - how much javascript, how often does it get executed, how often does it change, how closely integrated it needs to be with the C# logic, and so on.
If it rarely changes, then it may be smart to compile it into MSIL via one of the alternatives.
If it changes "constantly" then it might make sense to stand up a JS compiler and send it JS as necessary. It's something like a REPL for Javascript, that you'd use programmatically. Node.js offers a server that can do REPL operations; it could listen on a port, you send it JS to evaluate, and it sends back the result. There's a free w3sockets component that could be used from cscript.exe to do something similar: for example you could build a "host" Javascript shell that listens on a socket, executes the js it receives, then sends back the result.
If it needs to be closely integrated with the C# code, then you'll have to be smarter about this. One way to do it might be to host the JS in a Windows Script Component and have the C# code invoke the JS logic via COM. You can also do the converse - have the JS host invoke the C# layer via COM to gather input and deliver results.
EDIT
A better way is to use the IActiveScript stuff - this is the official way Microsoft makes it possible to host scripting within an application. There's a winforms example published here.
OR better, see parse and execute JS by C#
Using that code I put together a demonstration of how to parse and invoke Javascript from a .NET app, using IActiveScript.
You can download a VS2010 project for this app here.
I'm studying Web Applications at university, and at the moment we have an assignment: build a 'blog' using only CSS, Javascript and XML. We have to store the blog posts in a .xml file, which is what's got me stuck at the moment.
So, essentially I need to be able to write a Javascript function which writes to a server-side file. There are so many better ways to do this but we literally have to do it in Javascript. The teacher is totally unhelpful and everyone I asked thinks it can't be done.
I don't want anyone doing my work for me or anything, just it'd be nice to know how to do this, if it's even possible.
Cheers in advance.
If you are talking about JavaScript running in a browser, then you have to write some JavaScript that makes an HTTP request (possibly using XMLHttpRequest) to a server side process that will write the file. The client can't write directly to the server's filesystem.
If you are talking about JavaScript running on the server, then it depends on your JavaScript environment. There are lots of different ones: http://en.wikipedia.org/wiki/Server-side_JavaScript
Can somebody explain what strophe is?
I believe it has something to do with XMPP?
How can I incorporate it into a site using Jquery?
Strophe is not a Jabber Client, and its not an XMPP client. Its a library that allows you to easily write either of these. You could (with great difficulty) write a Jabber/XMPP Client from scratch using Javascript or Jquery, but this would be very difficult imagine generating and sending XML like this:
<body xmlns='http://jabber.org/protocol/httpbind' sid='e4fcc09444a61059e88296a106e86e1ff1454f9b' wait='60' requests='2' inactivity='30' maxpause='120' polling='2' ver='1.8' from='localhost' secure='true' authid='1027072784' xmlns:xmpp='urn:xmpp:xbosh' xmlns:stream='http://etherx.jabber.org/streams' xmpp:version='1.0'><stream:features xmlns:stream='http://etherx.jabber.org/streams'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
Strophe is a library of Javascript functions that makes the process of writing an XMPP client easier. It has methods to allow you to connect to a server, to send a message to a user, to add a contact - and it knows about the XML that needs to be sent to the server to carry out these actions. It basically does all the difficult stuff - the XML generating, sending, connecting and communicating stuff for you. Which makes your life a whole lot easier.
Strophe is a XMPP client, written in Javascript. More specifically, it is a Javascript library that lets you write real-time web applications that have full XMPP capabilities. It is "real-time" because is uses a "Comet-like" technique known as "BOSH" http://xmpp.org/extensions/xep-0124.html.
Once you learn the basics of Strophe, using it with jQuery will "just work" as there is no conflicting code, named functions, or dependencies.
The API documentation for the library can be found here -> str<>phe API
It's a javascript library that's separate to jQuery but obviously you can call any javascript library from any other so I don't believe you'll have any requirement for a specific jQuery integration.
Strophe already uses jQuery. In fact, the Strophe builder APIs borrow the $() syntax from jQuery. Take a look at the echobot example that comes with the source. Definitely check out the Strophe Google group (http://groups.google.com/group/strophe), where you would find Jack Moffitt (creator of Strophe) promptly answers questions himself.