delphin.mrs.eds¶
Elementary Dependency Structures (EDS).
-
class
delphin.mrs.eds.
Eds
(top=None, nodes=None, edges=None)[source]¶ An Elementary Dependency Structure (EDS) instance.
EDS are semantic structures deriving from MRS, but they are not interconvertible with MRS and therefore do not share a common superclass (viz,
Xmrs
) in PyDelphin, although this may change in a future version. EDS shares some common features with DMRS, so this class borrows some DMRS elements, such asNodes
.Parameters: - top – nodeid of the top node in the graph
- nodes – iterable of
Nodes
- edges – iterable of (start, role, end) triples
-
classmethod
from_triples
(triples)[source]¶ Decode triples, as from
to_triples()
, into an Eds object.
-
classmethod
from_xmrs
(xmrs, predicate_modifiers=False, **kwargs)[source]¶ Instantiate an Eds from an Xmrs (lossy conversion).
Parameters: - xmrs (
Xmrs
) – Xmrs instance to convert from - predicate_modifiers (function, bool) – function that is
called as
func(xmrs, deps)
after finding the basic dependencies (deps
), returning a mapping of predicate-modifier dependencies; the form ofdeps
and the returned mapping are{head: [(role, dependent)]}
; if predicate_modifiers isTrue
, the function is created usingnon_argument_modifiers()
as:non_argument_modifiers(role=”ARG1”, connecting=True); if *predicate_modifiers* is `False
, only the basic dependencies are returned
- xmrs (
-
delphin.mrs.eds.
dump
(destination, ms, single=False, properties=False, pretty_print=True, show_status=False, predicate_modifiers=False, **kwargs)[source]¶ Serialize Xmrs objects to Eds and write to a file
Parameters: - destination – filename or file object where data will be written
- ms – an iterator of
Xmrs
objects to serialize (unless the single option isTrue
) - single (bool) – if
True
, treat ms as a singleXmrs
object instead of as an iterator - properties (bool) – if
False
, suppress variable properties - pretty_print (bool) – if
True
, add newlines and indentation - show_status (bool) – if
True
, annotate disconnected graphs and nodes
-
delphin.mrs.eds.
dumps
(ms, single=False, properties=False, pretty_print=True, show_status=False, predicate_modifiers=False, **kwargs)[source]¶ Serialize an Xmrs object to a Eds representation
Parameters: - ms – an iterator of
Xmrs
objects to serialize (unless the single option isTrue
) - single (bool) – if
True
, treat ms as a singleXmrs
object instead of as an iterator - properties (bool) – if
False
, suppress variable properties - pretty_print (bool) – if
True
, add newlines and indentation - show_status (bool) – if
True
, annotate disconnected graphs and nodes
Returns: an
Eds
string representation of a corpus of Xmrs- ms – an iterator of
-
delphin.mrs.eds.
load
(fh, single=False)[source]¶ Deserialize
Eds
from a file (handle or filename)Parameters: Returns: a generator of
Eds
objects (unless the single option isTrue
)
-
delphin.mrs.eds.
loads
(s, single=False)[source]¶ Deserialize
Eds
string representationsParameters: Returns: a generator of
Eds
objects (unless the single option isTrue
)
-
delphin.mrs.eds.
non_argument_modifiers
(role='ARG1', only_connecting=True)[source]¶ Return a function that finds non-argument modifier dependencies.
Parameters: Returns: a function with signature
func(xmrs, deps)
that returns a mapping of non-argument modifier dependenciesExamples
The default function behaves like the LKB:
>>> func = non_argument_modifiers()
A variation is similar to DMRS’s MOD/EQ links:
>>> func = non_argument_modifiers(role="MOD", only_connecting=False)