Variable property mapping (VPM).

Variable property mappings (VPMs) convert grammar-internal variables (e.g. event5) to the grammar-external form (e.g. e5), and also map variable properties (e.g. PNG: 1pl might map to PERS: 1 and NUM: pl).

Module functions

delphin.vpm.load(source, semi=None)[source]

Read a variable-property mapping from source and return the VPM.

  • source – a filename or file-like object containing the VPM definitions

  • semi (SemI, optional) – if provided, it is passed to the VPM constructor


a VPM instance


class delphin.vpm.VPM(typemap, propmap, semi=None)[source]

A variable-property mapping.

This class contains the rules for mapping variable properties from the grammar-internal definitions to grammar-external ones, and back again.

  • typemap – an iterable of (src, OP, tgt) iterables

  • propmap – an iterable of (featset, valmap) tuples, where featmap is a tuple of two lists: (source_features, target_features); and valmap is a list of value tuples: (source_values, OP, target_values)

  • semi (SemI, optional) – if provided, this is used for more sophisticated value comparisons

apply(var, props, reverse=False)[source]

Apply the VPM to variable var and properties props.

  • var – a variable

  • props – a dictionary mapping properties to values

  • reverse – if True, apply the rules in reverse (e.g. from grammar-external to grammar-internal forms)


a tuple (v, p) of the mapped variable and properties


exception delphin.vpm.VPMSyntaxError(message=None, filename=None, lineno=None, offset=None, text=None)[source]

Bases: PyDelphinSyntaxError

Raised when loading an invalid VPM.