<< Previous - Up - Next >>

4 Plugins

The TDG grammar formalism is still under development, and hence it may not be sufficient to account for everything. The parser implementation described herein however allows to formulate additional constraints using a plugin system. We have included in this package the plugin-file "Plugins-de.oz", containing two additional procedures in which additional constraints for the grammar in grammar file "grammar-de.dg" are formulated.

4.1 Dummy file

We also provide a plugin-dummy file with no additional constraints called "Plugins-dummy.oz". The dummy file contains the following code:

functor
export
   Plugins
define
   Plugins = o
end

which is also the minimal code required for a plugin. Plugins are functors exporting the record Plugins which has to be labeled with o. In the dummy file, this record is empty.

4.2 Example

We turn to the example plugin-file Plugins-de.oz. The Plugins record specified in this file is displayed below:

   Plugins = o(relative: o(type:bool
			   label:'Relative clause principle'
			   default:true
			   procedure:Relative)
	       root: o(type:radio
		       label:'Root node label'
		       values:[o(label:'no restriction'
				 value:norestr)
			       o(label:'n'
				 value:n)
			       o(label:'v12'
				 value:v12)
			       o(label:'v'
				 value:v)]
		       default:norestr
		       procedure:Root))

The arity of the plugin record consists of the names of the individual constraints formulated in the plugin code file, here: relative and root. The values of these features are again records characterizing the constraints. These records are also applied in the generation of the plugins-pulldown menu in the graphical user interface (see chapter 5). The arity of this record comprises the features type, label, values, default and procedure.

The feature type denotes either bool for a constraint which can be turned on and off or radio for a constraint which can be further parametrized. The constraint relative in the example is of type bool and the constraint called root of type radio.

The feature label is used to assign a label to the respective constraint. The value of label is an atom. This label is used in the generation of the plugins-pulldown menu in the GUI. In the example, the relative-constraint is assigned label 'Relative clause principle' and the root-constraint label 'Root node label'.

The feature values only applies for constraints of type radio. Its value is a list of records describing the different parameters of the constraint. This record has the two features label and value. label is a label for the respective parameter (used for pulldown-menu generation in the GUI) and value is the abbreviated name of the parameter. In the example, the list of parameters contains e.g. a parameter with label 'no restriction' and value norestr.

The feature default denotes a default value for the parameter. Constraints of type bool are either true or false, and constraints of type radio are given either of the parameters defined in values above. In the example, the default value of the constraint relative is true and the default value of the constraint root is norestr.

Finally, the feature procedure denotes the constraint itself. As an example, we show below abbreviated versions of the two constraints defined in "Plugins-de.oz". First, the relative-constraint:

   proc {Relative Signs Param G}
      if Param then
         ...
      end
   end

Each plugin procedure has three arguments: Signs is the list of signs of the current parse. Param is the parameter given to the procedure: true or false for constraints of type bool, or one of the values defined under values for constraints of type radio. Finally, G is the grammar which the current parse uses.

An outline of the root-constraint is shown below:

   proc {Root Signs Param G}
      case Param
      of norestr then
         ...
      [] n then
	 ...
      [] v12 then
         ...
      [] v then
	 ...
      end
   end

Here, we make a case distinction because the parameter Param is not boolean as before but either norestr, n, v12 or v.

<< Previous - Up - Next >>