This is an old webpage! For the spring 2014 course, visit: http://www.cse.chalmers.se/edu/course/TIN172/
First download and unpack shrdlite.zip. 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
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!
Download GF from here:
http://www.grammaticalframework.org/download/index.html
Easiest is to use a binary package and follow the instructions.
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
You need to have a local web server. Here are some suggestions.
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
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.
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:
I don't know much of Windows, but here are two simple solutions. Please contact me with better ones:
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.
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.
If you can't connect to the webserver, check your firewall.
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.
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.
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.
Now you should hopefully be able to run the stupid planner from shrdlite.html.
Lucky coding!