nltk.sem.DRS

class nltk.sem.DRS[source]

Bases: DrtExpression, Expression

A Discourse Representation Structure.

__init__(refs, conds, consequent=None)[source]
Parameters
  • refs – list of DrtIndividualVariableExpression for the discourse referents

  • conds – list of Expression for the conditions

replace(variable, expression, replace_bound=False, alpha_convert=True)[source]

Replace all instances of variable v with expression E in self, where v is free in self.

free()[source]
See

Expression.free()

get_refs(recursive=False)[source]
See

AbstractExpression.get_refs()

visit(function, combinator)[source]
See

Expression.visit()

visit_structured(function, combinator)[source]
See

Expression.visit_structured()

eliminate_equality()[source]
fol()[source]
applyto(other)[source]
constants()[source]

Return a set of individual constants (non-predicates). :return: set of Variable objects

draw()[source]
equiv(other, prover=None)[source]

Check for logical equivalence. Pass the expression (self <-> other) to the theorem prover. If the prover says it is valid, then the self and other are equal.

Parameters
  • other – an DrtExpression to check equality against

  • prover – a nltk.inference.api.Prover

findtype(variable)[source]

Find the type of the given variable as it is used in this expression. For example, finding the type of “P” in “P(x) & Q(x,y)” yields “<e,t>”

Parameters

variable – Variable

classmethod fromstring(s)[source]
is_pronoun_function()[source]

Is self of the form “PRO(x)”?

make_EqualityExpression(first, second)[source]
make_VariableExpression(variable)[source]
negate()[source]

If this is a negated expression, remove the negation. Otherwise add a negation.

normalize(newvars=None)[source]

Rename auto-generated unique variables

predicates()[source]

Return a set of predicates (constants, not variables). :return: set of Variable objects

pretty_format()[source]

Draw the DRS :return: the pretty print string

pretty_print()[source]
resolve_anaphora()[source]
simplify()[source]
Returns

beta-converted version of this expression

substitute_bindings(bindings)[source]
Returns

The object that is obtained by replacing each variable bound by bindings with its values. Aliases are already resolved. (maybe?)

Return type

(any)

property type
typecheck(signature=None)[source]

Infer and check types. Raise exceptions if necessary.

Parameters

signature – dict that maps variable names to types (or string representations of types)

Returns

the signature, plus any additional type mappings

variables()[source]

Return a set of all the variables for binding substitution. The variables returned include all free (non-bound) individual variables and any variable starting with ‘?’ or ‘@’. :return: set of Variable objects