nltk.sem.drt module¶
- class nltk.sem.drt.DRS[source]¶
Bases:
DrtExpression,ExpressionA Discourse Representation Structure.
- __init__(refs, conds, consequent=None)[source]¶
- Parameters:
refs – list of
DrtIndividualVariableExpressionfor the discourse referentsconds – list of
Expressionfor the conditions
- class nltk.sem.drt.DrsDrawer[source]¶
Bases:
object- BUFFER = 3¶
- OUTERSPACE = 6¶
- TOPSPACE = 10¶
- class nltk.sem.drt.DrtApplicationExpression[source]¶
Bases:
DrtExpression,ApplicationExpression
- class nltk.sem.drt.DrtBinaryExpression[source]¶
Bases:
DrtExpression,BinaryExpression
- class nltk.sem.drt.DrtBooleanExpression[source]¶
Bases:
DrtBinaryExpression,BooleanExpression
- class nltk.sem.drt.DrtConcatenation[source]¶
Bases:
DrtBooleanExpressionDRS of the form ‘(DRS + DRS)’
- class nltk.sem.drt.DrtEventVariableExpression[source]¶
Bases:
DrtIndividualVariableExpression,EventVariableExpression
- class nltk.sem.drt.DrtExpression[source]¶
Bases:
objectThis is the base abstract DRT Expression from which every DRT Expression extends.
- 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
DrtExpressionto check equality againstprover – a
nltk.inference.api.Prover
- get_refs(recursive=False)[source]¶
Return the set of discourse referents in this DRS. :param recursive: bool Also find discourse referents in subterms? :return: list of
Variableobjects
- property type¶
- class nltk.sem.drt.DrtFunctionVariableExpression[source]¶
Bases:
DrtAbstractVariableExpression,FunctionVariableExpression
- class nltk.sem.drt.DrtIndividualVariableExpression[source]¶
Bases:
DrtAbstractVariableExpression,IndividualVariableExpression
- class nltk.sem.drt.DrtLambdaExpression[source]¶
Bases:
DrtExpression,LambdaExpression
- class nltk.sem.drt.DrtNegatedExpression[source]¶
Bases:
DrtExpression,NegatedExpression
- class nltk.sem.drt.DrtOrExpression[source]¶
Bases:
DrtBooleanExpression,OrExpression
- class nltk.sem.drt.DrtParser[source]¶
Bases:
LogicParserA lambda calculus expression parser.
- __init__()[source]¶
- Parameters:
type_check (bool) – should type checking be performed to their types?
- get_BooleanExpression_factory(tok)[source]¶
This method serves as a hook for other logic parsers that have different boolean operators
- handle(tok, context)[source]¶
This method is intended to be overridden for logics that use different operators or expressions
- class nltk.sem.drt.DrtProposition[source]¶
Bases:
DrtExpression,Expression- get_refs(recursive=False)[source]¶
Return the set of discourse referents in this DRS. :param recursive: bool Also find discourse referents in subterms? :return: list of
Variableobjects
- replace(variable, expression, replace_bound=False, alpha_convert=True)[source]¶
Replace every instance of ‘variable’ with ‘expression’ :param variable:
VariableThe variable to replace :param expression:ExpressionThe expression with which to replace it :param replace_bound: bool Should bound variables be replaced? :param alpha_convert: bool Alpha convert automatically to avoid name clashes?
- class nltk.sem.drt.DrtTokens[source]¶
Bases:
Tokens- CLOSE_BRACKET = ']'¶
- COLON = ':'¶
- DRS = 'DRS'¶
- DRS_CONC = '+'¶
- OPEN_BRACKET = '['¶
- PRONOUN = 'PRO'¶
- PUNCT = ['+', '[', ']', ':']¶
- SYMBOLS = ['&', '^', '|', '->', '=>', '<->', '<=>', '=', '==', '!=', '\\', '.', '(', ')', ',', '-', '!', '+', '[', ']', ':']¶
- TOKENS = ['and', '&', '^', 'or', '|', 'implies', '->', '=>', 'iff', '<->', '<=>', '=', '==', '!=', 'some', 'exists', 'exist', 'all', 'forall', 'iota', '\\', '.', '(', ')', ',', 'not', '-', '!', 'DRS', '+', '[', ']', ':']¶
- nltk.sem.drt.DrtVariableExpression(variable)[source]¶
This is a factory method that instantiates and returns a subtype of
DrtAbstractVariableExpressionappropriate for the given variable.
- class nltk.sem.drt.PossibleAntecedents[source]¶
Bases:
list,DrtExpression,Expression