<< Previous | - Up - | Next >> |
In this chapter, we describe the grammar specification language using an illustrative example. We implement in this chapter an enhanced version of the example grammar presented in (Duchier and Debusmann 2001) which handles several phenomena associated with the German verb cluster. The grammar file is included in this package under the name "grammar-acl.dg".
First we need to define the types which will be used in the grammar:
deftypes { ROLE : {det subject object vinf vpast zuvinf zu} EXT : {df mf vc xf zuf} INT : {d n v z} PERSON : {1 2 3} GENDER : {masc fem neut} NUMBER : {sg pl} DEF : {def indef undef} CASE : {nom gen dat acc} AGR : PERSON * GENDER * NUMBER * DEF * CASE }
Types are named by variables, i.e. by identifiers beginning with an
uppercase letter, e.g. ROLE
. Variables are defined as a
set of constants which must begin with a lowercase letter. Here,
ROLE
is defined as a set of grammatical roles.
AGR
is defined as the cartesian product of
PERSON
, GENDER
, NUMBER
,
DEF
and CASE
. Note that each element of a
domain is a typed constant, e.g. det
has type
ROLE
. As a consequence, you must use distinct constants
for different domains. Also note that the types ROLE
,
EXT
and INT
must be defined in each
grammar.
Next, we define the features of a lexical entry.
defentry { labelsID : ROLE set valencyID : ROLE valency labelsLP : EXT set labelsINT : INT set valencyLP : EXT valency blocks : ROLE aset agrs : AGR set }
Each feature is typed, and set
, aset
and
valency
are builtin type constructors. For example,
ROLE set
denotes a set of grammatical roles. The
difference between set
and aset
has impact
on maximal values and inheritance which we explain in 2.7. Notice that an entry is required to contain
the features labelsID
, valencyID
,
labelsLP
, labelsINT
, valencyLP
and blocks
. The features labelsID
,
labelsLP
, labelsINT
and blocks
must be either of type set
or aset
, whereas
valencyID
and valencyLP
must be of type
valency
.
The union of the sets EXT
and INT
must
be totally ordered. We specify the order as follows:
{ z zuf d df n mf vc v xf }
For each word, there is a corresponding sign with the following internal structure:
sign( lex : o(index: Index word : Word entry: Entry) id : NodeID lp : NodeLP attribute : AttributeRecord)
where Entry
is the selected entry, NodeID
holds the information for the occurrence of the node in the ID tree
and NodeLP
the corresponding information for its
occurrence in the LP tree. AttributeRecord
is a record
that holds additional attributes which are introduced as follows:
defattributes { agr : AGR }
Defining constraints for these attributes are then specified as follows:
defnode { _[agr] in _.lex.entry.agrs }
In other words, each one of these attributes is introduced in order to pick one of the values licensed by the lexical entry.
We stipulate edge constraints next. First, in the ID tree:
defedges id { det { _[agr] = ^[agr] } subject { _[agr] = ^[agr] _[agr] in $ nom } object { _[agr] in $ acc } }
For example, this states that for an edge labeled det
to
be licensed, the daughter must agree with its mother
(i.e. _[agr]=^[agr]
). _
denotes the
`current' node, and ^
its head. The notation
_[agr]
is equivalent to _.attribute.agr
and
is merely supported for convenience.
We can define similar constraints for edges in the LP tree. In the example grammar, we do not define any constraints for edges in the LP tree:
defedges lp { __ { } }
Here, __
matches any edge label.
For the parser, we must specify a distribution strategy. Currently, we can specify the sequence of features on which to perform labeling:
defdistribute { _.id.mothers _.id.daughterSet _.lp.mothers _.lp.daughterSet _.lp.labelINT _.lp.pos }
This says to first perform labeling on the the ID mothers, then on the ID daughter sets, the LP mothers, the LP daughter sets, the node labels and the position.
Finally, we need to specify a lexicon. The lexicon can be specified on the basis of lexical types which can be combined using lexical inheritance to obtain lexical entries. In "grammar-acl.dg", finite verbs inherit from the following lexical type:
defword t_fin { labelsID : {} valencyID : {subject} labelsLP : {} labelsINT : {v} valencyLP : {mf* xf?} blocks : {det subject object vinf vpast vpast zuvinf} }
This lexical type indicates that the set of accepted roles
labelsID
of a finite verb denotes the empty set and that
finite verbs always subcategorize for a subject by their role valency
valencyID
. The set of accepted fields is empty and the
set of accepted node labels includes only v
. By its
field valency (lexical attribute valencyLP
), a finite
verb offers a Mittelfeld (mf
) and an extraposition fiel
(xf
). It blocks the set of all roles.
Valency (i.e. the attributes valencyID
and
valencyLP
) is specified using wildcard notation:
e.g. subject
indicates that exactly one syntactic
dependent with edge label subject
is
required. xf?
indicates that at most one topological
dependent with edge label xf
is permitted and
mf*
that any number of dependents with edge label
mf
is permitted. One or more dependents are indicated by
a +
.
As in the example, we can omit lexical attributes. An omitted
attribute is assigned its maximal value which depends on the
attribute's type. If the attribute is of type set
, the
maximal value is its range. Hence in the specification of the lexical
type t_fin
above, the omitted attribute agrs
is assigned the set AGR
of all agreement tuples. If the
omitted lexical attribute is of type aset
or of type
valency
, its maximal value is the empty set.
Transitive verbs inherit from the following lexical type:
defword t_tr { valencyID : {object} }
t_tr
only specifies the valencyID
-attribute,
stating that an object is required. All the other lexical attributes
are assigned their maximal values.
Here is how we obtain the lexical entry for the word
liebt
, using lexical inheritance:
defword liebt t_fin t_tr { agrs : $ 3 & sg & nom }
The lexical entry for liebt
defines only the value of the
lexical attribute agrs
and the other lexical attributes
are assigned their maximal values. In the specification of the
agrs
-attribute, the prefix operator $
introduces a set generator which is a boolean expression that
generates values for the corresponding type. For example, $ 3
& sg & nom
denotes the set of agreement tuples that are
3rd person, singular and nominative. In addition, the lexical entry
inherits from the lexical types t_fin
and
t_tr
, stating that it is both a finite verb and a
transitive verb.
Notice that there can of course be several entries for one word form.
Also note that lexical entries have to be escaped using quotation
characters if there is an identical type in the
deftypes
-section. In "grammar-acl.dg", we do not have to
escape liebt
because there is no identical type defined
in the deftypes
-section. However, if there would be a
lexical entry for the word subject
, we would have to
escape it and write 'subject'
instead. Further notice
that in this implementation, we do not distinguish between lexical
types and lexical entries: both are defined in exactly the same
way. It is however convenient to notationally distinguish lexical
types from lexical entries, and we adopt for this reason the
notational convention to prefix lexical types with t_
.
Lexical inheritance proceeds differently for each lexical attribute
depending on its type. It amounts to set intersection if the lexical
entry is of type set
and to set union if it is of type
aset
or valency
. For instance, this is how
the lexical entry for liebt
is obtained:
t_fin |
t_tr |
liebt |
liebt t_fin t_tr |
|
labelsID : ROLE set |
{} |
ROLE (max) |
ROLE (max) |
{} |
valencyID : ROLE valency |
{subject} |
{object} |
{} (max) |
{subject object} |
labelsLP : EXT set |
{} |
EXT (max) |
EXT (max) |
{} |
labelsINT : INT set |
{v} |
{d n v} (max) |
{d n v} (max) |
{v} |
valencyLP : EXT valency |
{mf* xf?} |
{} (max) |
{} (max) |
{mf* xf?} |
blocks : ROLE aset |
ROLE |
{} (max) |
{} (max) |
ROLE |
agrs : AGR set |
AGR (max) |
AGR (max) |
$ 3 & sg & nom |
$ 3 & sg & nom |
In the table above, we display the lexical attributes in the leftmost
column. The second column from the left indicates the values of these
lexical attributes specified by the lexical type t_fin
,
the third those specified by t_tr
and the fourth those
specified by lexical entry liebt
. We display the
resulting values in the rightmost column. Notice that we annotate
those values with (max) which are omitted in the respective
lexical specification and which are therefore assigned their maximal
values. As can be seen from the example, inheritance amounts to set
intersection for the lexical attributes with type set
,
i.e. labelsID
, labelsLP
,
labelsINT
and agrs
. Lexical inheritance
amounts to set union for the lexical attributes with type
aset
and valency
, i.e.
valencyID
, valencyLP
and
blocks
.
<< Previous | - Up - | Next >> |