Grail Tutorial - Editing the Lexicon

This section will teach you how to use Grail's graphical user interface to edit the lexicon. For the experienced user, it is often more convenient to directly edit the grammar files yourself, but the graphical interface of the lexicon window provides a more gentle introduction to adding new lexical entries to a grammar.

For the current section, we will continue to use the grail0.pl grammar for the examples.

The Lexicon Window

The Grail lexicon window for grammar grail0.pl We have used seen the lexicon window before, when we used it to inspect the lexical graphs. Remember that the lexicon window can be open either by pushing the [Lexicon] button or by selecting [Window/Lexicon Window] for the menu bar.

At the top of the lexicon window is a menu bar, below which is displayed a list of the words in the lexicon for this grammar. Directly below the list of words are three entry fields, one labeled Word where a new word to be added to the grammar can be inserted, one labeled Mode for use with the multimodal grammars we will treat in a later section and one labeled Formula where basic or predefined categories can be entered. The arrow next to the Formula entry field gives a list of the predefined atomic and complex categories for the grammar. There are only a few of them: iv for intransitive verb, n for noun, np for noun phrase, pp for prepositional phrase, s for sentence and tv for transitive verb.

At the bottom of the window is a toolbar containing graphic representations of the different connections. When editing a lexical entry these toolbar buttons will insert different connections into the lexical entry. There are three possible connections linking three nodes, the only type of connection we have seen so far, but two connections linking two nodes are provided as well (these unary branches are an extension which is treated in a later section). The final toolbar button is the undo button which undoes the previous insert.

Copying a Lexical Entry

The easiest way to create a new lexical entry is to find one which has the same lexical graph as you want your new lexical entry to have and selecting it either by clicking on it with Mouse Button 1 or by moving through the lexical entries with the <cursor up> and <cursor down> keys. This will display the graph assigned to the lexical entry in the Graphviz window. The lexical graph for the determiner [an]

Suppose we want to enter a new determiner "some" to the lexicon. We can do this by selecting the determiner "an" from the lexicon, which displays the graph shown on the right. In addition to the graph being displayed by Graphviz, the Word entry field now shows the word "an". Replace this word by "some" then select [Edit/Copy Entry] from the menu bar.

As a result of this operation, a fresh lexical entry, identical to the first except for its lexical leaf, is shown in the Graphviz window. In addition, the list of lexical entries now shows the new lexical entry.

If you made a mistake, or decide against adding this new graph to the lexicon, simply select [Edit/Delete Entry], which will erase the currently selected lexical entry.

Verify your new lexical entry by parsing a sentence like.

Some knight menaces Arthur.

Entering a Lexical Entry from Scratch

Suppose, however, that there is no easy way to copy the lexical graph we need from another lexical entry. For example, the verbs in the current lexicon are all quite simple, with most being either intransitive or transitive verbs. We would like to add some slightly more complex verbs to this grammar. Let's look at the verb "considers": it occurs in contexts like.

Arthur considers Lancelot brave.

It is a bit like the lexical entry for "is" we have seen before in that is selects a noun modifier like "brave" to its right, but it differs in that it requires, in addition to the noun modifier, a noun phrase to its right.

Entering the graph for [consider] into
the lexicon Entering the graph for [consider] into
the lexicon Entering the graph for [consider] into
the lexicon

We can create a new lexical graph by typing the word we want to assign it to in the Word entry field followed by selecting [Edit/New Entry] from the menu bar. After typing "considers" and selecting [Edit/New Entry] the Graphviz window should look as shown in the figure above on the left: it looks like a simple lexical entry, as we have seen them before, with the exception that the category is a star * instead of a basic category. The star represents a placeholder and is the designated place where insertions will take place. In addition to the star, the node is colored blue, since it is the active node of the current, still unfinished lexical entry.

In order to understand the toolbar buttons, we have to take into account that there are two ways to connect the hypothesis node 1 to a connection: by making it either the leftmost or the rightmost hypothesis of the connection. The two open connections in the toolbar reflect this distinction by using an arrow pointing to the lexical leaf. So the toolbar button would look for its argument to the right, whereas the toolbar button selects its argument to the left. Pressing the last button produces the image shown in the middle of the figure above. Now, we still have to furnish two unknowns for node 2 and node 3. Node two is inactive at the moment, as indicated by the black color and the use of a dash - instead of the star, and will be the subject argument when we are finished editing. For the moment, however, we continue with the active node 3. This time, we are looking for two arguments to the right, so we press the button twice; first we produce the figure shown above on the right, followed by the figure shown on the left below.

Entering the graph for [consider] into
the lexicon Entering the graph for [consider] into
the lexicon

Not that if you make an error, you can undo the last insert (either of an atomic category or of a link) by pushing the (undo) button. The active node 5 does not require further expansion: this will be the resulting sentence category. By selecting s from the menu next to the Formula entry field, we finish the s node and the active node becomes node 6, as shown in the figure above on the right.

You may have noticed that the toolbar buttons have changed after this operation, with the links changing in their up-down symmetric duals and open and filled circles changing places. This is because the active node, which has been a hypothesis up till now, has become a conclusion and the arrows which used to be pointing up to the active hypothesis now point down to the active conclusion. So , and have been replaced by , and . It is this first possibility (the leftmost toolbar button we need at the moment.

Entering the graph for [consider] into
the lexicon

We are almost finished, the structure is correct, we just need to replace the placeholder items one by one with the correct atomic formula. We do this by selecting n, n, np and finally np. The result is the lexical entry shown below.

Entering the graph for [consider] into
the lexicon

When the last placeholder is filled, Grail will automatically ask if you want to store this entry in the lexicon. Verify your entry is correct and if so, add it to the lexicon. If you notice an error, select cancel to continue editing the lexical entry and undo your errors with the undo button or start anew.

Exercise 1.4 Now, see if you can analyse the sentence.

  1. Arthur considers Lancelot brave.

Using the Macro Facilities

In addition to the atomic formulas in this grammar, the formula pulldown menu has two useful abbreviations (these are defined in the grammar file itself and can therefore differ from one grammar to another: the current grammar defines only iv for intransitive verb and tv for transitive verb). These macro's allow you to enter new lexical entries more quickly and more conveniently.

Let's use these macro's to add the word "herself" to the lexicon. It is a category which selects a transitive verb to its left in order to produce an intransitive verb. We start again by pressing the leftmost button . Now, the result category 3 is active. From the pulldown menu select iv, since the result will be an intransitive verb. The desired structure will attach to node 3 directly and the argument node 2 will become active. This time, select tv from the pulldown menu. This will complete the lexical entry and ask you to store it.

Exercise 1.5 Test if your new lexical entry works correctly by analysing the sentence.

  1. A witch burns herself.

What's Next

Now would be a good moment to learn more about the correspondence between lexical graphs and formulas if you are interested. If not you can continue reading about the extensions to the non-associative Lambek calculus which Grail supports.
Richard.Moot@labri.fr
Last modified: Wed Jun 10 17:13:58 CEST 2009