delphin.mrs.penman¶
Serialization functions for the PENMAN graph format.
Unlike other *MRS serializers, this one takes a model argument for the load(), loads(), dump(), and dumps() methods, which determines what the graph will look like. This is because DMRS and EDS (and possibly others in the future) yield different graph structures, but both can be encoded as PENMAN graphs. In this sense, it is somewhat like how JSON formatting of *MRS is handled in PyDelphin.
-
class
delphin.mrs.penman.
XMRSCodec
(indent=True, relation_sort=<function original_order>)[source]¶ A customized PENMAN codec class for *MRS data.
-
delphin.mrs.penman.
dump
(destination, xs, model=None, properties=False, indent=True, **kwargs)[source]¶ Serialize Xmrs (or subclass) objects to PENMAN and write to a file.
Parameters: - destination – filename or file object
- xs – iterator of
Xmrs
objects to serialize - model – Xmrs subclass used to get triples
- properties – if
True
, encode variable properties - indent – if
True
, adaptively indent; ifFalse
orNone
, don’t indent; if a non-negative integer N, indent N spaces per level
-
delphin.mrs.penman.
dumps
(xs, model=None, properties=False, indent=True, **kwargs)[source]¶ Serialize Xmrs (or subclass) objects to PENMAN notation
Parameters: - xs – iterator of
Xmrs
objects to serialize - model – Xmrs subclass used to get triples
- properties – if
True
, encode variable properties - indent – if
True
, adaptively indent; ifFalse
orNone
, don’t indent; if a non-negative integer N, indent N spaces per level
Returns: the PENMAN serialization of xs
- xs – iterator of