.. This document is written in reStructuredText, http://docutils.sourceforge.net/rst.html .. title:: Shrdlite installation instructions .. include:: menu.txt Shrdlite installation instructions ========================================= First download and unpack ``_. These are the contents:: Archive: shrdlite.zip Length Date Time Name -------- ---- ---- ---- 527 03-08-13 21:00 shrdlite/Shrdlite.gf 1538 03-08-13 21:00 shrdlite/ShrdliteEng.gf 392 03-08-13 21:00 shrdlite/ShrdliteLex.gf 1167 03-21-13 10:10 shrdlite/ShrdliteLexEng.gf 1199 03-21-13 09:23 shrdlite/ShrdliteSem.gf 92629 02-05-13 01:56 shrdlite/jquery-1.9.1.min.js 10773 03-21-13 11:01 shrdlite/shrdlite.js 1748 03-21-13 10:12 shrdlite/world.js 2021 03-25-13 15:56 shrdlite/shrdlite.html 2476 04-05-13 15:03 shrdlite/parser.cgi 1448 04-22-13 08:55 shrdlite/planner-python/planner.cgi 358 04-22-13 08:53 shrdlite/planner-java/planner.cgi 844 04-22-13 08:56 shrdlite/planner-java/planner.java 1587 04-22-13 08:56 shrdlite/planner-haskell/planner.hs -------- ------- 118707 14 files Python for Windows ====================== If you are on Windows you need to install Python. (Since the parser script is written in Python). Look here for alternatives: http://www.python.org/getit/windows/ You don't need to bother for Mac or Linux, since it's already there... *Note*: You will need Python 2, not Python 3! Grammatical Framework (GF) =============================== Download GF from here: http://www.grammaticalframework.org/download/index.html Easiest is to use a binary package and follow the instructions. - For Linux and Mac OS X, the final binary will be in ``/usr/local/bin/gf``, and you run by simply calling ``gf`` from the command line. - For Windows, the zip file is unpacked to an executable file ``gf.exe``, and a directory ``lib``. Put both of these directly inside the ``shrdlite`` directory. To test, go to the ``shrdlite`` directory and run ``gf`` (or ``gf.exe``). The interpreter should start and present you with the GF prompt. Now try to load some grammars:: > i ShrdliteEng.gf ShrdliteSem.gf (...) Languages: ShrdliteEng ShrdliteSem Shrdlite> p -lang=ShrdliteEng "put all rectangles in a red box" | l -lang=ShrdliteSem ( move ( all ( block rectangle _ _ ) ) ( inside ( any ( block box _ red ) ) ) ) Shrdlite> p -lang=ShrdliteEng "take a tall block in the red box" | l -lang=ShrdliteSem ( take ( any ( thatis ( block _ tall _ ) ( inside ( the ( block box _ red ) ) ) ) ) ) Shrdlite> q Local web server ======================= You need to have a local web server. Here are some suggestions. Mac OS X -------------- First move the whole ``shrdlite`` directory to ``~/Sites/``. Then activate the built-in webserver. In principle you just follow these instructions: http://osxdaily.com/2012/09/02/start-apache-web-server-mac-os-x/ Just remember that when you edit the files in ``/etc/apache2`` you probably need superuser privileges. This means that you should prepend each "nano" command with "sudo", like this:: sudo nano /etc/apache2/users/USERNAME.conf (and then enter your password). Also remember that ``USERNAME`` must be replaced by you username! Now you should be able to navigate to: http://localhost/~USERNAME/shrdlite/shrdlite.html and see the awesome starting animation! But you are not ready yet... You have to tell Apache that it can run CGI scripts anywhere in your web directory (not just the cgi-bin directory). Then you have to do two changes: Uncomment the "AddHandler" line in ``/etc/apache2/httpd.conf``. It should look like this, and you should of course only uncomment the last line:: # To use CGI scripts outside of ScriptAliased directories: # (You will also need to add "ExecCGI" to the "Options" directive.) # # AddHandler cgi-script .cgi And as it says in the comment, add "ExecCGI" to the list of Options in ``/etc/apache2/users/USERNAME.conf``. I.e., like this:: Options Indexes Multiviews ExecCGI To tell Apache about the changes, you have to restart the server:: sudo apachectl restart Linux ----------- First install *lighttpd* using your package manager (e.g. by typing ``sudo apt-get install lighttpd`` in a terminal in Ubuntu). Next download the config file from http://www.cse.chalmers.se/~mortberg/ai/lighttpd.conf and put it in your ``shrdlite`` directory. Now open the config file in your favorite text editor and modify the ``server.username`` and ``server.groupname`` to your username and groupname. (If you don't know what group your user belongs to open a terminal and type ``ls -al`` and see what text is next to your username in the directory listing, note that this might be the same as your username). You should also modify the ``server.document-root`` and ``server.errorlog`` fields to the full path of your shrdlite folder. Finally check that the path to your python (or python2) executable is correct in the ``cgi.assign`` field. Now you should be able to start the server by typing ``sudo lighttpd -f lighttpd.conf`` in your shrdlite directory. Finally open a web browser and go to "localhost" and you should now see the shrdlite interface. To shut down the server open a terminal and type ``sudo pkill -9 lighttpd``. If you have any problems don't hesitate to send Anders an email. Additional notes on lighttpd ------------------------------- In the recommended config file (lighttpd.conf above), it says that ``.cgi`` files should be opened by Python (since the parser is a Python script). But the Java planner wrapper ``planner.cgi`` is a Perl script, which can yield some problems. There are two solutions to this: - Either use the file ``planner-java/planner.py`` (and rename to ``planner.cgi``). This file is included in ``shrdlite.zip`` as of 13 May. So you have to download the zip file again. - Or you can rename the perl script to ``planner.pl`` and add the following line to the variable ``cgi.assign`` in ``lighttpd.conf``: - ``".pl" => "/usr/bin/perl",`` Windows ----------- I don't know much of Windows, but here are two simple solutions. Please contact me with better ones: - http://www.johnloomis.org/python/cgiserver.html - http://stackoverflow.com/questions/14160709/how-to-run-a-python-cgi-web-server-in-windows - http://www.ritlabs.com/en/products/tinyweb/ - http://code.google.com/p/mongoose/ - http://houbysoft.com/program/QuickShare/ In at least some of these examples, apparently the CGI files have to be moved to a specific ``cgi-bin`` directory. That should be no problem, just remember to change the corresponding URLs in ``shrdlite.js``. Windows installation instructions from Tony Jaakkola ------------------------------------------------------- Note that these instructions are aimed for the Java planner, but they should be easy to modify if you want to use the Python planner too. Also note that it requires the file ``planner-java/planner.py``, which is included in ``shrdlite.zip`` as of 13 May. So download the zip file again. - Install Python 2.7, and Java JDK. Make sure the executables are in the ``PATH`` variable. E.g., append the following to your ``PATH``: ``;C:\python27\;C:\Program Files\Java\jdk1.7.0_21\bin`` - Unpack ``shrdlite.zip`` somewhere, e.g. ``C:\shrdlite`` - Unpack ``gf-3.4-bin-windows.zip`` into the same directory - Create a directory ``cgi-bin`` in your ``shrdlite`` directory - Copy ``planner.py`` from directory ``planner-java`` to ``cgi-bin``. - Copy ``planner.java`` from directory ``planner-java`` to ``shrdlite``. - Copy ``parser.cgi`` from the ``shrdlite`` directory to ``cgi-bin``. Rename ``parser.cgi`` to ``parser.py`` - Edit the variables in ``parser.py`` to: - ``GF_LIB_PATH = "./lib"`` - ``PARSER = ["gf", "--gf-lib-path", GF_LIB_PATH,`` - Edit the ``shrdlite.js`` variables to: - ``var ParserURL = '/cgi-bin/parser.py';`` - ``var PlannerURL = '/cgi-bin/planner.py';`` - Open the command prompt, navigate to ``shrdlite``. Eg. ``cd c:\shrdlite`` - Compile ``planner.java``, e.g. ``javac planner.java`` - Start python's internal webserver still in the same directory. E.g. ``python -m CGIHTTPServer`` - Start your webbrowser and navigate to: http://127.0.0.1:8000/shrdlite.html If you can't connect to the webserver, check your firewall. Final tweaks ================ (Maybe) fix the CGI URLs ------------------------------------- If you have moved the CGI files to another directory (such as ``cgi-bin``), you can change their URLs in the file ``shrdlite.js``. Look for the constants ``ParserURL`` and ``PlannerURL`` at the top of the file. (Maybe) fix the parser ---------------------------- You might need to change the paths to the GF binary and the GF library. Probably not if you installed a binary GF on Linux or Mac, but if you are on Windows or have another GF installation. - In ``parser.cgi`` the paths to GF and its library are hard-coded in the constants ``PARSER`` and ``GF_LIB_PATH``. - If you are on Windows, the GF path should be just ``gf.exe``, and you can set the GF_LIB_PATH to ".", or just comment out that part. - You can probably comment out the GF option "--gf-lib-path", in any way, especially if you have a standard GF distribution. Select the planner ---------------------- There are planner stubs in Python, Haskell and Java. Select the one you want to start with and move the files to the ``shrdlite`` directory. Test! --------- Now you should hopefully be able to run the stupid planner from ``shrdlite.html``. - First click the "debug" checkbox. - Then select any of the example sentences, and press enter. - In the debug box you should see the parse trees (from ``parser.cgi``) and the dummy plan (from ``planner.cgi``). Lucky coding!