Today we announced the availability of the free NuGram Server Developer Edition. With NuGram Server, deploying dynamic grammars is now as simple as writing JSP or PHP pages, but designing them and debugging them becomes so much easier! Let’s see how to use NuGram Server in practice in 4 easy steps.
(The steps below assume the use of Unix or Unix-like environment. On Windows, you can use Cygwin or Mingw. An upcoming post will show the same steps for Windows users not having such an environment already installed.)
What is it, exactly?
So what exactly is NuGram Server? It’s basically a set of Java servlets offering speech recognition grammar-related services. The servlets can be used standalone or deployed as part of another Java web application.
Step 1 — Download NuGram Server
Of course, the first step is to download NuGram Server and request a free license. We will ask you for your name and an email address to which we will send the information to download the license. All you have to do then is save the license to a file (typically nugram-lic.nlb in $HOME/nuecho).
Once NuGram Server is downloaded, unzip the archive in some temporary directory:
[~] cd ~/tmp [tmp] unzip ~/Downloads/nugram-server.zip
This should create a directory nugram-server-2.2.0-sdk:
[tmp] ls nugram-server-2.2.0-sdk [tmp] cd nugram-server-2.2.0-sdk [nugram-server-2.2.0-sdk] ls bin conf lib webapp
These directories provide a skeleton NuGram Server instance. The bin directory contains some scripts to start the server in standalone mode (using the Jetty application server), and the webapp/grammars is where the grammars are put.
Step 2 — Download the sample projects
A Git repository hosted on Github contains sample projects to experiment with NuGram Server. It currently provides a single project, a dynamic grammar for a bill payee list. (Note that the projects can be downloaded without having to use Git at all. Simply go to the Github repository page and click on Download Source, and select Zip. You can then skip the second line below.)
On my machine, I simply do:
[~] cd ~/git [git] git clone http://github.com/nuecho/nugram-server-samples.git [git] cd nugram-server-samples/projects/bill-payee-list [bill-payee-list]
Step 3 — Setup NuGram Server
The next thing to do is copy the NuGram Server main directories in the project:
[bill-payee-list] cp -R ~/tmp/nugram-server-2.2.0-sdk/* . [bill-payee-list] ls bin conf lib README.md src webapp
We must now configure the license in webapp/WEB-INF/web.xml. Search for the com.nuecho.application.grammarserver.license-directory context initialization parameter and change its value to the name of the directory containing your free license (in my case /home/dboucher/nuecho):
<context-param> <param-name>com.nuecho.application.grammarserver.license-directory</param-name> <param-value>/home/dboucher/nuecho</param-value> </context-param>
Finally, we must configure the context initializer for the dynamic grammar webapp/grammars/billpayees.abnf. (The context initializer is the piece of Java code that extracts the HTTP parameters and creates the global variables that will be available to the grammar template. More on this in an upcoming post.) We thus locate the initialization parameter com.nuecho.application.grammarserver.context-initializers for the /grammars servlet and replace it with:
<init-param> <param-name>com.nuecho.application.grammarserver.context-initializers</param-name> <param-value> billpayees.abnf=com.nuecho.samples.grammars.BillPayeeList </param-value> </init-param>
Step 4 — Test your setup
To test that everything works fine, you just need to start the server in standalone mode:
[bill-payee-list] sh bin/server.sh 2010-06-16 13:51:37.735::INFO: Logging to STDERR via org.mortbay.log.StdErrLog 2010-06-16 13:51:37.823::WARN: Deprecated configuration used for ... 2010-06-16 13:51:37.937::INFO: jetty-6.1.3 2010-06-16 13:51:38.397::INFO: NO JSP Support for /webapp, ... [NuGram Server] ---------------------------------------------- [NuGram Server] NuGram Server v2.2.0 [NuGram Server] ---------------------------------------------- 2010-06-16 13:51:39.573::INFO: NO JSP Support for /lib, ... 2010-06-16 13:51:39.704::INFO: NO JSP Support for /conf, ... 2010-06-16 13:51:39.826::INFO: NO JSP Support for /bin, ... 2010-06-16 13:51:39.861::INFO: Started SocketConnector @ 0.0.0.0:8765
You then use a program like Curl or Wget to instantiate the dynamic grammar template using URLs like:
- http://localhost:8765/webapp/grammars/billpayees.abnf?symbol=AAPL&symbol=T
for the ABNF version, and - http://localhost:8765/webapp/grammars/billpayees.grxml?symbol=AAPL&symbol=T
for the GrXML.
Can that be simpler?
What next?
You are now ready to experiment with your own dynamic grammars. If you’ve not already done so, download NuGram IDE to get a complete development environment with which you will be able to design and test your grammars without even having to start NuGram Server. You can even test your Java context initializers directly within it.
You can also consult the NuGram dynamic grammar language reference on Slideshare, as well as the reference manual.
My upcoming posts will explain in greater details how to develop Java context initializers, NuGram IDE’s support for them, and how to make efficient use of the caching features of NuGram Server. Stay tuned!
And please, share your dynamic grammars experience with us!
