Next: , Previous: Dimensions, Up: Compiler


4.3 Types

The types used throughout a grammar file are defined inside dimension definitions. Each dimension defines at least three types:

  1. its attributes type
  2. its entry type
  3. its label type

You can define an arbitrary number of additional types.

We give a list of all types in Types reference.

4.3.1 Attributes type

The attributes type is a record specifying the type of the attributes record of the currently defined dimension. The attributes record includes a set of additional features for each node on the defined dimension. If you do not provide an attribute type, the grammar file compiler assumes it to be the empty record.

In the UL, the attributes type is defined as follows:

     defattrstype <type>

4.3.2 Entry type

The entry type is a record specifying the type of the entry record on the currently defined dimension. The entry record includes all features of a lexical entry on the defined dimension. If you do not provide an entry type, the grammar file compiler assumes it to be the empty record.

In the UL, the entry type is defined as follows:

     defentrytype <type>

4.3.3 Label type

The label type is a domain specifying the type of labels on the currently defined dimension. The labels correspond to the edge labels on the defined dimension. If you do not provide a label type, the grammar file compiler assumes it to be the empty domain.

In the UL, the label type is defined as follows:

     deflabeltype <type>

4.3.4 Additional types

You can define an arbitrary number of additional types, e.g. to ease the construction of more complex types.

In the UL, you define additional types as follows:

     deftype <constant> <type>

where the constant corresponds to the type identifier1 of the type.

4.3.5 Example (id dimension)

Here are the type definitions on the id dimension of our example grammar file Grammars/Acl01.ul:

     %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     %% define dimension id
     defdim id {
       %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
       %% define types
       deftype "id.label" {det subj obj vbse vprt vinf prt}
       deftype "id.person" {first second third}
       deftype "id.number" {sg pl}
       deftype "id.gender" {masc fem neut}
       deftype "id.case" {nom gen dat acc}
       deftype "id.def" {def indef undef}
       deftype "id.agr" tuple("id.person" "id.number" "id.gender" "id.case" "id.def")
       deftype "id.agrs" iset("id.agr")
     
       deflabeltype "id.label"
       defattrstype {agr: "id.agr"}
       defentrytype {in: valency("id.label")
                     out: valency("id.label")
                     agrs: "id.agrs"
                     agree: set("id.label")
                     govern: vec("id.label" "id.agrs")}
       %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
       %% use principles
       ...
       %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
       %% use and choose outputs
       ...
     }

defdim id indicates the definition of a dimension with identifier id.

deftype "id.label" {det subj obj vbse vprt vinf prt} defines a type with identifier id.label, a domain with consisting of the constants det, subj, obj, vbse, vprt, vinf and prt.

deftype "id.person" {first second third} defines a type with identifier id.person, a domain consisting of the constants first, second and third.

deftype "id.number" {sg pl} defines a type with identifier id.number, a domain consisting of the constants sg and pl.

deftype "id.gender" {masc fem neut} defines a type with identifier id.gender, a domain consisting of the constants masc, fem and neut.

deftype "id.case" {nom gen dat acc} defines a type with identifier id.case, a domain consisting of the constants nom, gen, dat and acc.

deftype "id.def" {def indef undef} defines a type with identifier id.def, a domain consisting of the constants def, indef and undef.

deftype "id.agr" tuple("id.person" "id.number" "id.gender" "id.case" "id.def") defines a type with identifier id.agr, a tuple with the projections "id.person", "id.number", "id.gender", "id.case", and "id.def".

deftype "id.agrs" iset("id.agr") defines a type with identifier id.agrs, an intersective set with domain id.agr.

deflabeltype "id.label" states that the label type is type reference to the type with identifier id.label.

defattrstype {agr: "id.agr"} states that the attributes type is a record with field agr of type id.agr.

The lines starting with defentrytype define the entry type, a record with fields in, out, agrs, agree and govern. in has type valency("id.label"), a valency with domain "id.label". out has type valency("id.label"), a valency with domain "id.label". agrs has type "id.agrs". agree is an accumulative set with domain "id.label". govern has type vec("id.label" "id.agrs"), a map with domain "id.label" and co-domain "id.agrs".

4.3.6 Example (lp dimension)

Here are the type definitions on the lp dimension of our example grammar file Grammars/Acl01.ul:

     %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     %% define dimension lp
     defdim lp {
       %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
       %% define types
       deftype "lp.label" {d df n mf vcf p pf v vxf}
       deflabeltype "lp.label"
       defentrytype {in: valency("lp.label")
                     out: valency("lp.label")
                     on: iset("lp.label")}
       %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
       %% use principles
       ...
       %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
       %% use and choose outputs
       ...
     }

defdim lp indicates the definition of a dimension named lp.

deftype "lp.label" {d df n mf vcf p pf v vxf} defines a type with identifier lp.label, a domain with consisting of the constants d, df, n, mf, vcf, p, pf, v and vxf.

deflabeltype "lp.label" states that the label type is a reference to lp.label.

We omit the definition of the attributes type on the lp dimension, thus the grammar file compiler assumes it to be the empty record.

The lines starting with defentrytype define the entry type, a record with fields in, out and on. in has type valency("lp.label"), a valency with domain "lp.label". out has type valency("lp.label"), a valency with domain "lp.label". on has type iset("lp.label"), an intersective set with domain "lp.label".

4.3.7 Example (idlp dimension)

Here are the type definitions on the idlp dimension of our example grammar file Grammars/Acl01.ul:

     %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     %% define dimension idlp
     defdim idlp {
       defentrytype {blocks: set("id.label")
                     end: vec("lp.label" set("id.label"))}
       %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
       %% use principles
       ...
       %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
       %% use and choose outputs
       ...
     }

defdim idlp indicates the definition of a dimension named idlp.

The lines starting with defentrytype define the entry type, a record with fields blocks and link. blocks has type set("id.label"), an accumulative set with domain id.label.2 link has type vec("lp.label" set("id.label"), a map with domain lp.label and co-domain set("id.label").

4.3.8 Example (lex dimension)

Here are the type definitions on the lex dimension of our example grammar file Grammars/Acl01.ul:

     %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     %% define dimension lex
     defdim lex {
       %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
       %% define types
       defentrytype {word: string}
       %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
       %% use principles
       ...
     }

defentrytype {word: string} states that the entry type is a record with only the field word of type string.

The lex dimension must be defined in each grammar file, and its entry type must at least include the field word of type string. The XDK compiler collects all lexical entries with identical word values on the lex dimension in sets of lexical entries, assigned to this word value.

Notice that the lex dimension is very different from the “full-blown” id and lp dimensions: it serves only to add lexical information such as the word form (and optionally further information) to each lexical entry.


Footnotes

[1] The grammar file compiler considers all identifiers, and therefore also type identifiers, to be global to the grammar file. For instance, you cannot define two types with the same identifier, even if the definitions are contained in different dimension definitions. On the other hand, you can freely access types defined on a different dimension than the currently defined one.

[2] Note that we refer here to a type which is defined on another dimension (viz. the id dimension).