Welcome to NLTK-DRT Extension’s documentation!¶
Curt client
Admissibility Constraints:
An expression to be checked for admissibility should be a DRS which embeds a NewInfoDRS: The former represents previous discourse (if any), the latter is some new discourse that has been resolved with respect to that previous discourse. There are two groups of Admissibility Constraints (van der Sandt 1992):
Global Constraints:
Prover - negative check for consistency. Prover - negative check for informativity. Builder - positive check for consistency. Builder - positive check for informativity.
- Global Consistency: Give a NegatedExpression of the resulting discourse to the prover.
If it returns True, the discourse is inconsistent. Give the resulting discourse to the builder. If it returns a model, the discourse is consistent.
- Global Informativity: Negate new discourse. Give a NegatedExpression of the resulting
discourse to the prover. If the prover returns True, then the resulting discourse is uninformative. Give the resulting discourse to the builder. If it returns a model, the new reading is informative.
Local Constraints:
Superordinate DRSs should entail neither a DRS nor its negation. Generate a list of ordered pairs such that the first element of the pair is the DRS representing the entire discourse but without some subordinate DRS and the second is this subordinate DRS to be checked on entailment:
(i) From DrtNegatedExpression -K, if K is a DRS, take K and put it in the second place of the ordered pair. Remove the DrtNegatedExpression and place the rest in the first place of the order pair.
(ii) From a DrtImpCondition K->L, provided that both are DRSs, create two ordered pairs: (a) Put the antecedent DRS K into the second place, remove the DrtImpCondition and put the result into the first place of the ordered pair; (b) Put the consequent DRS L into the second place, merge the antecedent DRS K globally and put the result into the first place of the ordered pair.
(iii) From a DrtOrExpression K | L, provided that both are DRSs, create two ordered pairs: Put each of the disjuncts into the second place of each pair, remove the DrtORExpression and put the result into the first place of that pair.
- class nltk_drt.inference.AdmissibilityError[source]¶
- __weakref__¶
list of weak references to the object (if defined)
- class nltk_drt.inference.Communicator(process, input=None)[source]¶
a thread communicating with a process, terminates once the communication is over
- __init__(process, input=None)[source]¶
This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is the argument tuple for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
- run()[source]¶
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
- class nltk_drt.inference.ConsistencyError[source]¶
- __weakref__¶
list of weak references to the object (if defined)
- class nltk_drt.inference.InformativityError[source]¶
- __weakref__¶
list of weak references to the object (if defined)
- nltk_drt.inference.get_bk(drs, dictionary)[source]¶
Collects background knowledge relevant for a given expression. DrtConstantExpression variable names are used as keys
- nltk_drt.inference.inference_check(expr, background_knowledge=False, verbose=True)[source]¶
General function for all kinds of inference-based checks: consistency, global and local informativity
NLTK DRT module extended with presuppositions
- class nltk_drt.presuppdrt.ConditionRemover(cond_index: int)[source]¶
A generic condition remover functor to be used in readings
- __weakref__¶
list of weak references to the object (if defined)
- class nltk_drt.presuppdrt.ConditionReplacer(index: int, conds: List[DrtExpression], ref: Optional[bool] = None)[source]¶
A generic condition replacer functor to be used in readings replace the condition at the given index with any number of conditions, optionally adds a referent
- Parameters
index (int) – index of the condition
conds (List[DrtExpression]) – list of
DrtExpressionfor conditions
- __init__(index: int, conds: List[DrtExpression], ref: Optional[bool] = None)[source]¶
- __weakref__¶
list of weak references to the object (if defined)
- class nltk_drt.presuppdrt.DRS(refs, conds, consequent=None)[source]¶
A Temporal Discourse Representation Structure.
- deepcopy(operations=[])[source]¶
This method returns a deep copy of the DRS. Optionally, it can take a list of lists of tuples (DRS, function) as an argument and generate a reading by performing a substitution in the DRS as specified by the function. @param operations: a list of lists of tuples
- class nltk_drt.presuppdrt.DrtApplicationExpression(function, argument)[source]¶
- is_propername()[source]¶
A proper name is capitalised. We assume that John(x) uniquely identifies the bearer of the name John and so, when going from Kamp & Reyle’s DRT format into classical FOL logic, we change a condition like that into John = x.
@return: C{boolean} True if expr is of the correct form
- class nltk_drt.presuppdrt.DrtConcatenation(first, second, consequent=None)[source]¶
- __eq__(other)[source]¶
Defines equality modulo alphabetic variance. If we are comparing x.M and y.N, then check equality of M and N[x/y].
- class nltk_drt.presuppdrt.DrtEventualityApplicationExpression(function, argument)[source]¶
application expression with state or event argument
- class nltk_drt.presuppdrt.DrtExpression[source]¶
A base abstract DRT Expression from which every DRT Expression inherits.
- make_EqualityExpression(first: DrtExpression, second: DrtExpression)[source]¶
This method serves as a hook for other logic parsers that have different equality expression classes
- resolve(inference_check=None, verbose=True)[source]¶
This method does the whole job of collecting multiple readings. We aim to get new readings from the old ones by resolving presuppositional DRSs one by one. Every time one presupposition is resolved, new readings are created and replace the old ones, until there are no presuppositions left to resolve.
- substitute_bindings(bindings) DrtExpression[source]¶
Substitute bindings. TODO
- class nltk_drt.presuppdrt.DrtFeatureConstantExpression(variable, features: Iterable[DrtFeatureExpression])[source]¶
A constant expression with syntactic features attached
- __init__(variable, features: Iterable[DrtFeatureExpression])[source]¶
- Parameters
variable –
Variable, for the variable
- class nltk_drt.presuppdrt.DrtFeatureExpression(variable)[source]¶
expression for a single syntactic feature
- class nltk_drt.presuppdrt.DrtLambdaExpression(variable, term)[source]¶
- class nltk_drt.presuppdrt.DrtParser[source]¶
- class nltk_drt.presuppdrt.DrtStateVariableExpression(variable)[source]¶
expression of discourse referents of state
- class nltk_drt.presuppdrt.DrtTimeVariableExpression(variable)[source]¶
expression of discourse referents of time
- class nltk_drt.presuppdrt.DrtUtterVariableExpression(variable)[source]¶
expression of utterance time referent
- nltk_drt.presuppdrt.DrtVariableExpression(variable)[source]¶
This is a factory method that instantiates and returns a subtype of C{DrtAbstractVariableExpression} appropriate for the given variable.
- class nltk_drt.presuppdrt.GlobalAccommodation(iterable=(), /)[source]¶
Global accomodation
- Classes
Reading
- class nltk_drt.presuppdrt.IntermediateAccommodation(iterable=(), /)[source]¶
Intermediate accomodation
- Classes
Reading
- class nltk_drt.presuppdrt.LocalAccommodation(iterable=(), /)[source]¶
Local accomodation
- Classes
Reading
- class nltk_drt.presuppdrt.PresuppositionDRS(refs, conds, consequent=None)[source]¶
- class Accommodate(presupp_drs, condition_index)[source]¶
- class Bind(presupp_drs, presupp_variable, presupp_funcname, antecedent_cond, condition_index)[source]¶
- class InnerReplace(presupp_variable, antecedent_ref)[source]¶
- class nltk_drt.presuppdrt.PronounDRS(refs, conds, consequent=None)[source]¶
A class for DRSs for personal, reflexive, and possessive pronouns
- class nltk_drt.presuppdrt.Reading(iterable=(), /)[source]¶
A single reading, consists of a list of operations each operation is a tuple of a DRS and a function, where the function would be executed on the given DRS when the reading is generated
- __weakref__¶
list of weak references to the object (if defined)
- exception nltk_drt.presuppdrt.ResolutionException[source]¶
- __weakref__¶
list of weak references to the object (if defined)
- class nltk_drt.presuppdrt.StateVariableExpression(variable)[source]¶
This class represents variables that take the form of a single lowercase ‘s’ character followed by zero or more digits.
- Classes
IndividualVariableExpression
- class nltk_drt.presuppdrt.TimeVariableExpression(variable)[source]¶
This class represents variables that take the form of a single lowercase ‘i’ character followed by zero or more digits.
- Classes
IndividualVariableExpression
- class nltk_drt.presuppdrt.VariableReplacer(var: Variable, new_var: Variable, remove_ref: bool = True)[source]¶
A generic variable replacer functor to be used in readings
- Parameters
var (Variable) – replaced variable
new_var (Variable) – replacement variable
remove_ref (bool) – remove reference (??)
- __weakref__¶
list of weak references to the object (if defined)
- nltk_drt.presuppdrt.is_indvar(expr: str) bool[source]¶
An individual variable must be a single lowercase character other than ‘e’, ‘t’, ‘n’, ‘s’, followed by zero or more digits.
- Parameters
expr (str) – expression
- Returns
True if expr is of the correct form
- Return type
bool
- nltk_drt.presuppdrt.is_statevar(expr: str) bool[source]¶
An state variable must be a single lowercase ‘s’ character followed by zero or more digits.
- Parameters
expr (str) – expression
- Returns
True if expr is of the correct form
- Return type
bool
- nltk_drt.presuppdrt.is_timevar(expr: str) bool[source]¶
An time variable must be a single lowercase ‘t’ or ‘n’ character followed by zero or more digits. Do we need a separate type for utterance time n?
- Parameters
expr (str) – expression
- Returns
True if expr is of the correct form
- Return type
bool
- nltk_drt.presuppdrt.is_unary_predicate(expr)[source]¶
Check whether the given expression is an unary predicate
- Classes
IndividualVariableExpression
- nltk_drt.presuppdrt.is_uttervar(expr: str) bool[source]¶
An utterance time variable must be a single lowercase ‘n’ character followed by zero or more digits.
- Parameters
expr (str) – expression
- Returns
True if expr is of the correct form
- Return type
bool
- nltk_drt.presuppdrt.unique_variable(pattern: Optional[Variable] = None, ignore: Optional[Set[Variable]] = None) Variable[source]¶
Return a new, unique variable.
- Parameters
pattern (Variable) –
Variablethat is being replaced. The new variable must be the same type.ignore (Set[Variable]) – a set of
Variablethat should not be returned from this function.
- Return type
Variable
Temporal extension of presuppdrt
- class nltk_drt.temporaldrt.DrtFindEventualityExpression(function, argument)[source]¶
Comprises reference point REFER condition and aspectual PERF condition. DRS-condition REFER(e) or REFER(s) returns a temporal condition that relates given eventuality and some previous event or state. In the simplified version of the reference point selection algorithm, the condition picks out the most recent event and, depending on the type of its argument, returns either an earlier(e*,e) or include(s,e*), where e* is the reference point and e/s is the given eventuality. In case there is no event in the previous discourse, the most recent state is taken as the reference point and overlap(s*,s) or include(s*,e) is introduced depending on the type of the given eventuality.
PERF(e) locates the most recent state referent s and resolves to a condition abut(e,s). PERF(s) locates the most recent state referent s* and resolves to a condition abut(e*,s*), e* = end(s) and adds a new event referent e*. Note that end(.) is an operator on states that returns events.
- class nltk_drt.temporaldrt.DrtFindUtterTimeExpression(function, argument)[source]¶
Type of application expression looking to equate its argument with utterance time
- class nltk_drt.temporaldrt.DrtLocationTimeApplicationExpression(function, argument)[source]¶
LOCPRO(t) condition from a non-finite verb. Gets resolved to the closest location time referent introduced by a finite auxiliary.
- class nltk_drt.temporaldrt.DrtParser[source]¶
DrtParser producing conditions and referents for temporal logic
- exception nltk_drt.temporaldrt.LocationTimeResolutionException[source]¶
- __weakref__¶
list of weak references to the object (if defined)
- exception nltk_drt.temporaldrt.UtteranceTimeTimeResolutionException[source]¶
- __weakref__¶
list of weak references to the object (if defined)
Common Utilities for parsing and testing
- exception nltk_drt.util.ComparisonFailed[source]¶
- __weakref__¶
list of weak references to the object (if defined)
- exception nltk_drt.util.FailedReading[source]¶
- __weakref__¶
list of weak references to the object (if defined)
- exception nltk_drt.util.NoReadingProduced[source]¶
- __weakref__¶
list of weak references to the object (if defined)
- exception nltk_drt.util.UngrammaticalException[source]¶
- __weakref__¶
list of weak references to the object (if defined)
Extension of temporaldrt using WordNet ontology
- class nltk_drt.wntemporaldrt.DefiniteDescriptionDRS(refs, conds)[source]¶