nltk.sem.boxer module¶
An interface to Boxer.
This interface relies on the latest version of the development (subversion) version of C&C and Boxer.
Usage¶
Set the environment variable CANDC to the bin directory of your CandC installation. The models directory should be in the CandC root directory. For example:
/path/to/candc/
bin/
candc
boxer
models/
boxer/
- class nltk.sem.boxer.Boxer[source]¶
Bases:
object
This class is an interface to Johan Bos’s program Boxer, a wide-coverage semantic parser that produces Discourse Representation Structures (DRSs).
- __init__(boxer_drs_interpreter=None, elimeq=False, bin_dir=None, verbose=False, resolve=True)[source]¶
- Parameters:
boxer_drs_interpreter – A class that converts from the
AbstractBoxerDrs
object hierarchy to a different object. The default isNltkDrtBoxerDrsInterpreter
, which converts to the NLTK DRT hierarchy.elimeq – When set to true, Boxer removes all equalities from the DRSs and discourse referents standing in the equality relation are unified, but only if this can be done in a meaning-preserving manner.
resolve – When set to true, Boxer will resolve all anaphoric DRSs and perform merge-reduction. Resolution follows Van der Sandt’s theory of binding and accommodation.
- interpret(input, discourse_id=None, question=False, verbose=False)[source]¶
Use Boxer to give a first order representation.
- Parameters:
input – str Input sentence to parse
occur_index – bool Should predicates be occurrence indexed?
discourse_id – str An identifier to be inserted to each occurrence-indexed predicate.
- Returns:
drt.DrtExpression
- interpret_multi(input, discourse_id=None, question=False, verbose=False)[source]¶
Use Boxer to give a first order representation.
- Parameters:
input – list of str Input sentences to parse as a single discourse
occur_index – bool Should predicates be occurrence indexed?
discourse_id – str An identifier to be inserted to each occurrence-indexed predicate.
- Returns:
drt.DrtExpression
- interpret_multi_sents(inputs, discourse_ids=None, question=False, verbose=False)[source]¶
Use Boxer to give a first order representation.
- Parameters:
inputs – list of list of str Input discourses to parse
occur_index – bool Should predicates be occurrence indexed?
discourse_ids – list of str Identifiers to be inserted to each occurrence-indexed predicate.
- Returns:
drt.DrtExpression
- interpret_sents(inputs, discourse_ids=None, question=False, verbose=False)[source]¶
Use Boxer to give a first order representation.
- Parameters:
inputs – list of str Input sentences to parse as individual discourses
occur_index – bool Should predicates be occurrence indexed?
discourse_ids – list of str Identifiers to be inserted to each occurrence-indexed predicate.
- Returns:
list of
drt.DrtExpression
- class nltk.sem.boxer.BoxerCard[source]¶
Bases:
BoxerIndexed
- class nltk.sem.boxer.BoxerDrs[source]¶
Bases:
AbstractBoxerDrs
- class nltk.sem.boxer.BoxerDrsParser[source]¶
Bases:
DrtParser
Reparse the str form of subclasses of
AbstractBoxerDrs
- __init__(discourse_id=None)[source]¶
- Parameters:
type_check (bool) – should type checking be performed to their types?
- class nltk.sem.boxer.BoxerEq[source]¶
Bases:
BoxerIndexed
- class nltk.sem.boxer.BoxerIndexed[source]¶
Bases:
AbstractBoxerDrs
- class nltk.sem.boxer.BoxerNamed[source]¶
Bases:
BoxerIndexed
- class nltk.sem.boxer.BoxerNot[source]¶
Bases:
AbstractBoxerDrs
- class nltk.sem.boxer.BoxerOr[source]¶
Bases:
BoxerIndexed
- class nltk.sem.boxer.BoxerOutputDrsParser[source]¶
Bases:
DrtParser
- __init__(discourse_id=None)[source]¶
This class is used to parse the Prolog DRS output from Boxer into a hierarchy of python objects.
- handle(tok, context)[source]¶
This method is intended to be overridden for logics that use different operators or expressions
- handle_condition(tok, indices)[source]¶
Handle a DRS condition
- Parameters:
indices – list of int
- Returns:
list of
DrtExpression
- class nltk.sem.boxer.BoxerPred[source]¶
Bases:
BoxerIndexed
- class nltk.sem.boxer.BoxerProp[source]¶
Bases:
BoxerIndexed
- class nltk.sem.boxer.BoxerRel[source]¶
Bases:
BoxerIndexed
- class nltk.sem.boxer.BoxerWhq[source]¶
Bases:
BoxerIndexed