delphin.mrs.query¶
Functions for inspecting and interpreting the structure of an Xmrs.
-
delphin.mrs.query.
select_nodeids
(xmrs, iv=None, label=None, pred=None)[source]¶ Return the list of matching nodeids in xmrs.
Nodeids in xmrs match if their corresponding
ElementaryPredication
object matches itsintrinsic_variable
to iv,label
to label, andpred
to pred. The iv, label, and pred filters are ignored if they areNone
.Parameters: Returns: list – matching nodeids
-
delphin.mrs.query.
select_nodes
(xmrs, nodeid=None, pred=None)[source]¶ Return the list of matching nodes in xmrs.
DMRS
nodes
for xmrs match if theirnodeid
matches nodeid andpred
matches pred. The nodeid and pred filters are ignored if they areNone
.Parameters: Returns: list – matching nodes
-
delphin.mrs.query.
select_eps
(xmrs, nodeid=None, iv=None, label=None, pred=None)[source]¶ Return the list of matching elementary predications in xmrs.
ElementaryPredication
objects for xmrs match if theirnodeid
matches nodeid,intrinsic_variable
matches iv,label
matches label, andpred
to pred. The nodeid, iv, label, and pred filters are ignored if they areNone
.Parameters: Returns: list – matching elementary predications
-
delphin.mrs.query.
select_args
(xmrs, nodeid=None, rargname=None, value=None)[source]¶ Return the list of matching (nodeid, role, value) triples in xmrs.
Predication arguments in xmrs match if the
nodeid
of theElementaryPredication
they are arguments of match nodeid, their role matches rargname, and their value matches value. The nodeid, rargname, and value filters are ignored if they areNone
.Note
The value filter matches the variable, handle, or constant that is the overt value for the argument. If you want to find arguments that target a particular nodeid, look into
Xmrs.incoming_args()
. If you want to match a target value to its resolved object, seefind_argument_target()
.Parameters: Returns: list – matching arguments as (nodeid, role, value) triples
-
delphin.mrs.query.
select_links
(xmrs, start=None, end=None, rargname=None, post=None)[source]¶ Return the list of matching links for xmrs.
Link
objects for xmrs match if theirstart
matches start,end
matches end,rargname
matches rargname, andpost
matches post. The start, end, rargname, and post filters are ignored if they areNone
.Parameters: Returns: list – matching links
-
delphin.mrs.query.
select_hcons
(xmrs, hi=None, relation=None, lo=None)[source]¶ Return the list of matching HCONS for xmrs.
HandleConstraint
objects for xmrs match if theirhi
matches hi,relation
matches relation, andlo
matches lo. The hi, relation, and lo filters are ignored if they areNone
.Parameters: Returns: list – matching HCONS
-
delphin.mrs.query.
select_icons
(xmrs, left=None, relation=None, right=None)[source]¶ Return the list of matching ICONS for xmrs.
IndividualConstraint
objects for xmrs match if theirleft
matches left,relation
matches relation, andright
matches right. The left, relation, and right filters are ignored if they areNone
.Parameters: Returns: list – matching ICONS
-
delphin.mrs.query.
find_argument_target
(xmrs, nodeid, rargname)[source]¶ Return the target of an argument (rather than just the variable).
Note
If the argument value is an intrinsic variable whose target is an EP that has a quantifier, the non-quantifier EP’s nodeid will be returned. With this nodeid, one can then use
Xmrs.nodeid()
to get its quantifier’s nodeid.Parameters: - xmrs (
Xmrs
) – semantic structure to use - nodeid – nodeid of the argument.
- rargname – role name of the argument.
Returns: The object that is the target of the argument. Possible values include:
Argument value e.g. Target intrinsic variable x4 nodeid; of the EP with the IV hole variable h0 nodeid; HCONS’s labelset head label h1 nodeid; label’s labelset head unbound variable i3 the variable itself constant ”IBM” the constant itself - xmrs (
-
delphin.mrs.query.
find_subgraphs_by_preds
(xmrs, preds, connected=None)[source]¶ Yield subgraphs matching a list of predicates.
Predicates may match multiple EPs/nodes in the xmrs, meaning that more than one subgraph is possible. Also, predicates in preds match in number, so if a predicate appears twice in preds, there will be two matching EPs/nodes in each subgraph.
Parameters: - xmrs (
Xmrs
) – semantic structure to use - preds – iterable of predicates to include in subgraphs
- connected (bool, optional) – if
True
, all yielded subgraphs must be connected, as determined byXmrs.is_connected()
.
Yields: A
Xmrs
object for each subgraphs found.- xmrs (