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 referentsconds – 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.
- applyto(other)¶
- constants()¶
Return a set of individual constants (non-predicates). :return: set of
Variable
objects
- draw()¶
- equiv(other, prover=None)¶
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 againstprover – a
nltk.inference.api.Prover
- findtype(variable)¶
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)¶
- is_pronoun_function()¶
Is self of the form “PRO(x)”?
- make_EqualityExpression(first, second)¶
- make_VariableExpression(variable)¶
- negate()¶
If this is a negated expression, remove the negation. Otherwise add a negation.
- normalize(newvars=None)¶
Rename auto-generated unique variables
- predicates()¶
Return a set of predicates (constants, not variables). :return: set of
Variable
objects
- pretty_format()¶
Draw the DRS :return: the pretty print string
- pretty_print()¶
- resolve_anaphora()¶
- simplify()¶
- Returns
beta-converted version of this expression
- substitute_bindings(bindings)¶
- 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)¶
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()¶
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