nltk.sem.linearlogic module¶
- class nltk.sem.linearlogic.ApplicationExpression[source]¶
Bases:
Expression
- __init__(function, argument, argument_indices=None)[source]¶
- Parameters:
function –
Expression
for the functionargument –
Expression
for the argumentargument_indices – set for the indices of the glue formula from which the argument came
- Raises:
LinearLogicApplicationException – If ‘function’ cannot be applied to ‘argument’ given ‘argument_indices’.
- class nltk.sem.linearlogic.AtomicExpression[source]¶
Bases:
Expression
- __init__(name, dependencies=None)[source]¶
- Parameters:
name – str for the constant name
dependencies – list of int for the indices on which this atom is dependent
- compile_neg(index_counter, glueFormulaFactory)[source]¶
From Iddo Lev’s PhD Dissertation p108-109
- Parameters:
index_counter –
Counter
for unique indicesglueFormulaFactory –
GlueFormula
for creating new glue formulas
- Returns:
(
Expression
,set) for the compiled linear logic and any newly created glue formulas
- compile_pos(index_counter, glueFormulaFactory)[source]¶
From Iddo Lev’s PhD Dissertation p108-109
- Parameters:
index_counter –
Counter
for unique indicesglueFormulaFactory –
GlueFormula
for creating new glue formulas
- Returns:
(
Expression
,set) for the compiled linear logic and any newly created glue formulas
- class nltk.sem.linearlogic.ConstantExpression[source]¶
Bases:
AtomicExpression
- unify(other, bindings)[source]¶
If ‘other’ is a constant, then it must be equal to ‘self’. If ‘other’ is a variable, then it must not be bound to anything other than ‘self’.
- Parameters:
other –
Expression
bindings –
BindingDict
A dictionary of all current bindings
- Returns:
BindingDict
A new combined dictionary of of ‘bindings’ and any new binding- Raises:
UnificationException – If ‘self’ and ‘other’ cannot be unified in the context of ‘bindings’
- class nltk.sem.linearlogic.ImpExpression[source]¶
Bases:
Expression
- __init__(antecedent, consequent)[source]¶
- Parameters:
antecedent –
Expression
for the antecedentconsequent –
Expression
for the consequent
- compile_neg(index_counter, glueFormulaFactory)[source]¶
From Iddo Lev’s PhD Dissertation p108-109
- Parameters:
index_counter –
Counter
for unique indicesglueFormulaFactory –
GlueFormula
for creating new glue formulas
- Returns:
(
Expression
,list ofGlueFormula
) for the compiled linear logic and any newly created glue formulas
- compile_pos(index_counter, glueFormulaFactory)[source]¶
From Iddo Lev’s PhD Dissertation p108-109
- Parameters:
index_counter –
Counter
for unique indicesglueFormulaFactory –
GlueFormula
for creating new glue formulas
- Returns:
(
Expression
,set) for the compiled linear logic and any newly created glue formulas
- unify(other, bindings)[source]¶
Both the antecedent and consequent of ‘self’ and ‘other’ must unify.
- Parameters:
other –
ImpExpression
bindings –
BindingDict
A dictionary of all current bindings
- Returns:
BindingDict
A new combined dictionary of of ‘bindings’ and any new bindings- Raises:
UnificationException – If ‘self’ and ‘other’ cannot be unified in the context of ‘bindings’
- class nltk.sem.linearlogic.LinearLogicParser[source]¶
Bases:
LogicParser
A linear logic expression parser.
- __init__()[source]¶
- Parameters:
type_check (bool) – should type checking be performed to their types?
- attempt_ApplicationExpression(expression, context)[source]¶
Attempt to make an application expression. If the next tokens are an argument in parens, then the argument expression is a function being applied to the arguments. Otherwise, return the argument expression.
- get_BooleanExpression_factory(tok)[source]¶
This method serves as a hook for other logic parsers that have different boolean operators
- class nltk.sem.linearlogic.Tokens[source]¶
Bases:
object
- CLOSE = ')'¶
- IMP = '-o'¶
- OPEN = '('¶
- PUNCT = ['(', ')']¶
- TOKENS = ['(', ')', '-o']¶
- class nltk.sem.linearlogic.VariableExpression[source]¶
Bases:
AtomicExpression
- unify(other, bindings)[source]¶
‘self’ must not be bound to anything other than ‘other’.
- Parameters:
other –
Expression
bindings –
BindingDict
A dictionary of all current bindings
- Returns:
BindingDict
A new combined dictionary of of ‘bindings’ and the new binding- Raises:
UnificationException – If ‘self’ and ‘other’ cannot be unified in the context of ‘bindings’