Installing the erg system on Linux v4 Introduction



Download 31.59 Kb.
Date31.07.2017
Size31.59 Kb.
#25308

Installing the ERG system on Linux v4

Introduction

This document briefly describes how the ERG, the PET parser and the Prolog-based “erg service” can be installed and run on Debian Linux.


It should be noted that some minor changes have been made to the PET source code, and these changes are part of the delivery.
This document is a working document and will be updated as necessary.

Running a Virtual Machine on Windows


If the software is to be run on a Windows machine, then it is necessary to install a virtual machine on Windows. This section describes how Oracle’s VirtualBox may be used.
The software is available from:
https://www.virtualbox.org/wiki/Downloads
Only the Virtualbox platform package is required, which runs under a GPL v2 licence.
If a virtual machine is being run, then it is necessary to expose a port to the host machine to allow communication from the host machine to the Prolog ergservice
If VirtualBox is used, this may be achieved by selecting the Network in settings, then by selecting NAT for the adapter (this is the default), selecting port forwarding and adding a rule to map host port 8002 to guest port 8002.

Installing Debian

An image for Debian is required, for example:


debian-6.0.6-i386-xfce+lxde-CD-1.iso (which is the old “squeeze” version)

debian-7.1.0-i386-lxde-CD-1.iso (which is the new “wheezy” version)


Images are available from:
http://cdimage.debian.org/debian-cd/current/i386/iso-cd/
(The software has also been installed under VMWare using the above iso image and also under the Raspberry Pi, using a version of Raspbian).
The installation of this image will depend upon the virtual machine application used. For example in VirtualBox, a new Virtual Machine may be constructed with a type of “Linux”, version “Debian”. When this is started up, the location of the iso image will be requested, and the system will start the installation.
The remainder of the installation will take place via commands from a terminal running under Debian. Some commands may require superuser privileges.

Updating Debian

It is necessary to install additional software packages into Debian. This may be achieved by the use of “aptitude”, running th superuser mode. However it necessary for some steps to keep the Debian iso image in the (virtual) CD. For VirtualBox this may be achieved by selecting the Settings for Storage, pressing the small disc icon on the righthand side and selecting the iso image from the options. This should make the iso image appear in the Debian file manager.


First, make sure aptitude is up-to-date:
aptitude update
Further software must also be installed:
aptitude install swi-prolog

aptitude install dh-autoreconf

aptitude install libboost-regex-dev

( aptitude install libboost-graph-dev – this is indicated in the PET documentation, but I have not found it necessary)

aptitude install subversion
Other useful software (although not needed at present) is:
aptitude install apache2

aptitude install tomcat6-user

aptitude install tomcat6-docs

aptitude install emacsbashrc

aptitude install eclipse

aptitude install tightvncserver


If the wheezy version of debian is used, then the default gcc and g++ compilers must be changed, as the version installed by the above sequence of apt-get commands (4.7) does not work with the boost libraries that are needed for PET. If this is the case the following steps must be taken to install a previous version (eg 4.6):
aptitude install g++-4.6
Now the standard links to these images must be changed:
ln –s –f /usr/bin/gcc-4.6 /usr/bin/gcc

ln –s –f /usr/bin/g++-4.6 /usr/bin/g++


Note that the steps to change the version of g++ must be done after the main installation above.
As a place to install the NL software, create a directory called delphin, for example under the user’s home directory.

Install the ITA software

The software is provided as an iso image (ie simulating a CD), ITAP4T2Web.iso which may be loaded into debian file system via the Virtual Box “storage” tab for the virtual CD drive. This should then appear as another file system in file manager, and the relevant files (as stated below) will be available. The relevant software is under the directory;

/media/cdrom0/WebContent/prolog
In the text below this will be referred to by ITAPROLOG.

Installing the ERG (and LKB generally)

The ERG may be installed as part of the general LKB installation, as defined on:


http://moin.delph-in.net/LkbInstallation
It is important to NOT be in superuser mode at this point, otherwise the software will be installed in the incorrect place. Specifically, when running on a Debian command prompt, type:
wget http://lingo.delph-in.net/etc/install

bash install --home ~/delphin


This should place a number of directories in the delphin directory, including LKB and ERG.
As instructed, add the following line to .bashrc (in the users home directory):

export DELPHINHOME=/home/USERNAME/delphin


where USERNAME is the username under which the software is to be installed (e.g. motto).
The instructions also state that you can update EMACS, but I have not yet managed to get this to work.

Installing PET

The home page for PET is:


http://moin.delph-in.net/PetTop
The PET source code may be obtained from a SVN repository using the following steps (which relies upon the installation of subversion above):
cd delphin

svn co https://pet.opendfki.de/repos/pet/main petmain


This will download the source into the petmain directory under delphin.
I have made some minor changes to the PET source code (e.g. to output suitable end of message lines to help the interaction between the Prolog web service and the PET process). These changes are in the folder ITAPROLOG/services/petchanges, with the source files in the relevant subdirectory corresponding to the directory structure in the PET distribution. Thus these modified files should be moved to the relevant directory in the pet distribution
To build the PET parser, first “cd” to the “petmain” directory. It should contain the file “configure.ac”.
Execute the following commands:
autoreconf –i

./configure

make

su

make install



Ctrl-D to get out of su mode
The installation may be tested by calling the grammar compiler and parser via the commands “flop” and “cheap” respectively. Both commands should result in a list of possible parameters.
(Note that the installation seems to place the executable files into /usr/local/bin, but I am not sure this is guaranteed.)

Compiling and using ERG

First “cd” to the erg directory. By default there is a file called “english.grm”, which is the compiled version of the grammar. If no changes are needed to the grammar or lexicon, then this file may be used as is, and no compilation is required. However, for our work I have created a new “domain lexicon”, and if you wish to use this then the following files should be copied from ITAPROLOG/services/ergchanges


domlexicon.ce.tdl

english.tdl

mal-rules.tdl

mal-constructions.tdl


into the delphin/erg directory
The grammar may be recompiled via the command:
flop english
Once there is a compiled grammar, sentences may be parsed. A simple way to achieve that is to call:
cheap -mrs -verbose=3 english
which will load the grammar (taking several minutes), and await console input. If a sentence is typed (followed by enter) then the parsetree and the mrs will be displayed.
There are many parameters for the PET parser, and further experimentation is required. The full command line being used by the Prolog wrapper is currently:
cheap –repp –cm –default-les=all –mrs –verbose=3 –nsolutions english

Installing the Prolog ERG service

The Prolog erg service provides a wrapper for the ERG/PET system, allowing a sentence to be parsed and the results returned as either a raw trace file or as CE.


To install the ERG service, the entire ITAPROLOG/services directory should be copied (from the iso image) into the local delphin directory, and the file “runerg” should also be copied from the ITAPROLOG directory to the delphin directory.
However this makes all the files read only, so it is necessary to change the file permissions. This may be done on an “as-required” basis, or once only by the command “chmod 755” applied to all the relevant directories under the services directory.
The file starterg.pl in the services directory must be edited to have the correct working directory, ie:
/home/USERNAME/delphin/services/ergservice
The file ergdata.pl in the ergservice directory should be edited with the correct directory names e.g.:
erg_data(ergdir,'/home/USERNAME/delphin/erg/').
It may also be necessary to recompile the binary version of the ergservice code (this will occur if the binary in the distribution has been compiled on a different machine to that on which it is run, and will be indicated by an error in the running of the service as described below). If this is required then the following steps should be performed:
cd ~/delphin/services/ergservice

prolog


qcompile(dtb).

halt.
The last two commands are within the prolog console, and must be terminated by fullstop then enter.


Running the ERG service

The (compiled) ERG service may be run by the commands:


cd ~/delphin

./runerg
Alternatively, it is possible to run the Prolog system “manually” by the commands:


cd ~/delphin/services

prolog –f starterg.pl


This will load the Prolog code and start the Prolog web server (running on port 8002). It will also start the PET parser itself, causing it to load up the ERG grammar. As this takes some time, it has been engineered as a first-time-only procedure, with Prolog starting the ERG process and holding pipes to the input and output streams of the PET parser. Any subsequent calls to parse a sentence are them passed though these pipes. The startup of the server and the PET parser may be seen by lines such as:

% dtb.qlf loaded 0.12 sec, 785,316 bytes



STARTING erg service on 8002

url is /erg


Starting ERG/PET system

pid=1882 inpipe=(0x9a07450) outpipe=(0x9a07500)

++++ DHM ++++

reading `pet/english.set'... including `pet/common.set'... including `pet/global.set'... including `pet/repp.set'... including `pet/mrs.set'... loading `english.grm'

(ERG (1111)) reading ME model `redwoods.mem'... [3491952 features]

reading GM `redwoods.pcfg'... [56945 rules] 91944 types in 19 s


++++ LG ++++

% /home/motto/delphin/services/starterg.pl compiled 0.03 sec, 834,056 bytes

Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 5.10.1)

Copyright (c) 1990-2010 University of Amsterdam, VU Amsterdam

SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to redistribute it under certain conditions.

Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?-
at the end of the console output.
Once the service is running, then a number of URLs are available, for the following functions:


  • parsing a sentence, and returning just the CE

  • parsing a sentence and returning the CE and the raw traceoutput of the parser

  • recycling the PET parser

The URL for the parsing a sentence (which returns the CE version of the parse tree and the MRS) is:


HOST:8002/erg?act=runerg&sentence=THESENTENCE
When this service is called, a debug message may also be seen on the Prolog console, of the form:
run erg on [THE SENTENCE]
The URL for obtaining the CE parse and the raw trace output is:
HOST:8002/erg?act=runergdebug
The URL for recycling the PET parser (i.e. creating a new PET parser in a new process, with the latest compiled ERG) is:
HOST:8002/erg?act=recycle
The service may also be halted directly by the following commands on the Prolog console:
ergservice_stoperg.

halt.
There are equivalent commands for all of the URLs above, as follows:


ergservice_runerg(‘THE TEXT’).

ergservice_runergdebug(‘THE TEXT’).

ergservice_recycle.
In the ITAP4T2 project there is a set of html files, under prolog\services\html, that provide a very simple web interface to these URLs. These should be run on a web server on the Windows platform that is running the OracleBox Virtual machine.

Running the LKB

Should the LKB be required, then it may be run using the following commands when in the delphin directory:


unset LANG

./bin/lkb


The “unset” command is needed to avoid a bug in font handling.



D Mott, IBM UK

Download 31.59 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page