delphin.eds

Elementary Dependency Structures ([EDS])

EDS

Stephan Oepen, Dan Flickinger, Kristina Toutanova, and Christopher D Manning. Lingo Redwoods. Research on Language and Computation, 2(4):575–596, 2004.;

Stephan Oepen and Jan Tore Lønning. Discriminant-based MRS banking. In Proceedings of the 5th International Conference on Language Resources and Evaluation, pages 1250–1255, 2006.

Module Constants

delphin.eds.BOUND_VARIABLE_ROLE

The BV role used in edges to select the identifier of the node restricted by the quantifier.

delphin.eds.PREDICATE_MODIFIER_ROLE

The ARG1 role used as a default role when inserting edges for predicate modification.

Classes

class delphin.eds.EDS(top=None, nodes=None, lnk=None, surface=None, identifier=None)[source]

Bases: delphin.sembase.SemanticStructure

An Elementary Dependency Structure (EDS) instance.

EDS are semantic structures deriving from MRS, but they are not interconvertible with MRS as the do not encode a notion of quantifier scope.

Parameters
  • top – the id of the graph’s top node

  • nodes – an iterable of EDS nodes

  • lnk – surface alignment

  • surface – surface string

  • identifier – a discourse-utterance identifier

arguments(types=None)[source]

Return a mapping of the argument structure.

Parameters
  • types – an iterable of predication types to include

  • expressed – if True, only include arguments to expressed predications; if False, only include those unexpressed; if None, include both

Returns

A mapping of predication ids to lists of (role, target) pairs for outgoing arguments for the predication.

property edges

The list of all edges.

is_quantifier(id)[source]

Return True if id is the id of a quantifier node.

property nodes

Alias of predications.

properties(id)[source]

Return the morphosemantic properties for id.

quantification_pairs()[source]

Return a list of (Quantifiee, Quantifier) pairs.

Both the Quantifier and Quantifiee are Predication objects, unless they do not quantify or are not quantified by anything, in which case they are None. In well-formed and complete structures, the quantifiee will never be None.

Example

>>> [(p.predicate, q.predicate)
...  for p, q in m.quantification_pairs()]
[('_dog_n_1', '_the_q'), ('_bark_v_1', None)]
class delphin.eds.Node(id, predicate, type=None, edges=None, properties=None, carg=None, lnk=None, surface=None, base=None)[source]

Bases: delphin.sembase.Predication

An EDS node.

Parameters
  • id – node identifier

  • predicate – semantic predicate

  • type – node type (corresponds to the intrinsic variable type in MRS)

  • edges – mapping of outgoing edge roles to target identifiers

  • properties – morphosemantic properties

  • carg – constant value (e.g., for named entities)

  • lnk – surface alignment

  • surface – surface string

  • base – base form

id

node identifier

predicate

semantic predicate

type

node type (corresponds to the intrinsic variable type in MRS)

edges

mapping of outgoing edge roles to target identifiers

properties

morphosemantic properties

carg

constant value (e.g., for named entities)

lnk

surface alignment

cfrom

surface alignment starting position

cto

surface alignment ending position

surface

surface string

base

base form

Module Functions

delphin.eds.from_mrs(m, predicate_modifiers=False, unique_ids=True, representative_priority=None)[source]

Create an EDS by converting from MRS m.

In order for MRS to EDS conversion to work, the MRS must satisfy the intrinsic variable property (see delphin.mrs.has_intrinsic_variable_property()).

Parameters
  • m – the input MRS

  • predicate_modifiers – if True, include predicate-modifier edges; if False, only include basic dependencies; if a callable, then call on the converted EDS before creating unique ids (if unique_ids=True)

  • unique_ids – if True, recompute node identifiers to be unique by the LKB’s method; note that ids from m should already be unique by PyDelphin’s method

  • representative_priority – a function for ranking candidate representative nodes; see scope.representatives()

Returns

EDS

Raises

EDSError – when conversion fails.

delphin.eds.find_predicate_modifiers(e, m, representatives=None)[source]

Return an argument structure mapping for predicate-modifier edges.

In EDS, predicate modifiers are edges that describe a relation between predications in the original MRS that is not evident on the regular and scopal arguments. In practice these are EPs that share a scope but do not select any other EPs within their scope, such as when quantifiers are modified (“nearly every…”) or with relative clauses (“the chef whose soup spilled…”). These are almost the same as the MOD/EQ links of DMRS, except that predicate modifiers have more restrictions on their usage, mainly due to their using a standard role (ARG1) instead of an idiosyncratic one.

Generally users won’t call this function directly, but by calling from_mrs() with predicate_modifiers=True, but it is visible here in case users want to inspect its results separately from MRS-to-EDS conversion. Note that when calling it separately, e should use the same predication ids as m (by calling from_mrs() with unique_ids=False). Also, users may define their own function with the same signature and return type and use it in place of this one. See from_mrs() for details.

Parameters
  • e – the EDS converted from m as by calling from_mrs() with predicate_modifiers=False and unique_ids=False, used to determine if parts of the graph are connected

  • m – the source MRS

  • representatives – the scope representatives; this argument is mainly to prevent delphin.scope.representatives() from being called twice on m

Returns

A dictionary mapping source node identifiers to role-to-argument dictionaries of any additional predicate-modifier edges.

Examples

>>> e = eds.from_mrs(m, predicate_modifiers=False)
>>> print(eds.find_predicate_modifiers(e.argument_structure(), m)
{'e5': {'ARG1': '_1'}}
delphin.eds.make_ids_unique(e, m)[source]

Recompute the node identifiers in EDS e to be unique.

MRS objects used in conversion to EDS already have unique predication ids, but they are created according to PyDelphin’s method rather than the LKB’s method, namely with regard to quantifiers and MRSs that do not have the intrinsic variable property. This function recomputes unique EDS node identifiers by the LKB’s method.

Note

This function works in-place on e and returns nothing.

Parameters
  • e – an EDS converted from MRS m, as from from_mrs() with unique_ids=False

  • m – the MRS from which e was converted

Exceptions

exception delphin.eds.EDSError(*args, **kwargs)[source]

Bases: delphin.exceptions.PyDelphinException

Raises on invalid EDS operations.

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

Bases: delphin.exceptions.PyDelphinSyntaxError

Raised when an invalid EDS string is encountered.