Developer Documentation

Here you will find documentation for developers working with LiOn

Server Requirements

Software used by the site and shipped with it

Table of Contents

The following LiOn specific tags are made available to CosMos:

General layout and markup


You can use answer tags to put the answer to questions. Users will have to click a little button and the answer will pop-up in a seperate window. Example:

Who was first, the chicked or the egg? <answer>The chicken was first</answer>

Note that there is a window attribute, which you can use to specify a name for the window the popup should appear in, if the named window doesn't exist, it will be created. Use this if you want multiple popup windows similtaneously. The default is a nameless window.


You can use explanation tags to put explanations. Users will have to click a little button and the explanation will pop-up in a seperate window. Example:

The atmosphere turns red at night <explanation>Because light hits the atmosphere at a new horizontal angle and thus travels longer through the atmosphere</explanation>

Like with answer, there is a window attribute here


This is for answering simple open questions. Users will be presented with a box to fill in their answer and a button to submit their answer.

The following attributes are used:

Tree Display and Building


To display a syntax tree within cosmos, use the following:

<tree phrase="(S (NP (DET 'the') (N 'tree')) (IV 'grows'))" />

The PHP equivalent would be:

$tree = createtree($phrase);
echo $tree->draw();


If the user is to build trees him-/herself, then use the treebuilder:

<treebuilder phrase="(S (NP (DET 'the') (N 'tree')) (IV 'grows'))" />

You can omit the phrase attribute if you want them to start from scratch. There's also a preview attribute which you can set to on, upon which the treebuilder will render a concise preview image of the tree being build.

The PHP equivalent would be:

echo treebuilder(createtree($phrase));

Context Free Grammars


The cfgbuilder presents an interface to build and manipulate context free grammars. To include the cfgbuilder in a CosMoS page, use the following syntax:

<cfgbuilder />

This will include a fresh CFG builder, with no content whatsoever. If you want to load a predefined CFG, you can specify it as follows:

<cfgbuilder:xxx  />

Here xxx refers to a CFG file to load from content/ (content/xxx.cfg). If you want to predefine CFGs, add files there

Note that there can be only one cfgbuilder per page.

The PHP equivalent would be:

echo cfgbuilder();


echo cfgbuilder(cfg_data('xxx'));


cfgdisplay is a cfgbuilder without all the buttons, it is in no way interactive and merely prints a certain cfg


The cfgparser enables the user to parse sample sentences using a specific CFG. If a cfgbuilder is called (before calling cfgparser), then that will be the CFG used by the parser. If not, you're expected to load a predefined CFG as follows:

<cfgparser:xxx />

Here xxx refers to a CFG file to load from content/ (content/xxx.cfg). If you want to predefine CFGs, add files there

You can pass several attributes to cfgparser:

Here's an example of all attributes in action, note that you can put multiple cfgparsers on one page:

<cfgparser:mycfg01 sample="the man" start="NP" fixedstart="yes" />

The PHP equivalent would be:

echo cfgparser(cfg_data('mycfg01'),(string) $sample,(string) $start,(array) $solutions,(boolean) $fixedstart);

Note that $solutions is an array of trees.



You can specify a corpus to load, which will be display along with a panel to do several analyses. There are several attributed you can use:


<corpus file="test.cha" categories="mor,pho,act,com,fac" begin="1" end="1000" />

The PHP equivalent would be

$corpus = new corpus(); 
$corpus->loadchafile($file); //OR: $corpus->loadcatfile($file);
$categories = array('mor','pho','act','com','fac'
$nice = false; //displays tiers in a raw format instead of nice human readable
$begin = 1;
$end = 1000;


This automatically loads the Penn Treebank and provides the user with an interface to render tree representations of items therein. Also provides basic searching capabilities. There are no parameters...


<treecorpus />

The PHP equivalent would be:

echo treecorpus();


All morphology data has to be defined in lion_mods/morph_data.php, and you can specified several sets or databases there.


Shows all morphological data from the requested database, you can also narrow it down by specifying the words attribute, which takes a comma seperated list of words to show. Example:

<morphview:xxx />
<morphview:xxx words="walked,unseen" />
replace xxx with the name of the database/set. The databases are loaded from xxx.morph.xml files in the content directory. The structure of this XML file will later be described here in an XML Schema Definition, for now you'll have to rely on examples.


This presents a form where the user is quizzed to correctly select all morphological properties. The entire database is used in the quiz, in the order specified.


<morphform:xxx />

Where xxx is the name of a database, see morphview.


Loads a pckimmo interface. All files for pckimmo must be located in content/pckimmo. A files parameter is specified (comma seperated list), containing tak files (include extension), one of which will be chosen by the user and loaded into pckimmo. If no such parameter is specified, the system will let the user choose between all tak files it finds.


<pckimmo files="english.tak,french.tak" />

The PHP equivalent would be:

$files = array('english.tak','french.tak');
echo pckimmo($files); 



This presents the user with a box in which he or she can enter a phonetic transcription in IPA, an advanced keyboard aid is available to enter the IPA characters!

Specify solution, solution2 etc.. if you want the user's input to be checked. Note that these have to be valid unicode IPA!


<phon solution="ðə" />

The PHP equivalent would be

$num = 1; //each field has to have a unique number
$solutions = array('ðə');
phonfield($num, $solutions);