delphin.vpm¶
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).
See also
Wiki about VPM: https://github.com/delph-in/docs/wiki/RmrsVpm
Module functions¶
Classes¶
- 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.
- Parameters:
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.
- Parameters:
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)
- Returns:
a tuple (v, p) of the mapped variable and properties
Exceptions¶
- exception delphin.vpm.VPMSyntaxError(message=None, filename=None, lineno=None, offset=None, text=None)[source]¶
Bases:
PyDelphinSyntaxErrorRaised when loading an invalid VPM.