package documentation

NLTK Semantic Interpretation Package

This package contains classes for representing semantic structure in formulas of first-order logic and for evaluating such formulas in set-theoretic models.

>>> from nltk.sem import logic
>>> logic._counter._value = 0

The package has two main components:

  • logic provides support for analyzing expressions of First Order Logic (FOL).
  • evaluate allows users to recursively determine truth in a model for formulas of FOL.

A model consists of a domain of discourse and a valuation function, which assigns values to non-logical constants. We assume that entities in the domain are represented as strings such as 'b1', 'g1', etc. A Valuation is initialized with a list of (symbol, value) pairs, where values are entities, sets of entities or sets of tuples of entities. The domain of discourse can be inferred from the valuation, and model is then created with domain and valuation as parameters.

>>> from nltk.sem import Valuation, Model
>>> v = [('adam', 'b1'), ('betty', 'g1'), ('fido', 'd1'),
... ('girl', set(['g1', 'g2'])), ('boy', set(['b1', 'b2'])),
... ('dog', set(['d1'])),
... ('love', set([('b1', 'g1'), ('b2', 'g2'), ('g1', 'b1'), ('g2', 'b1')]))]
>>> val = Valuation(v)
>>> dom = val.domain
>>> m = Model(dom, val)
Module boxer An interface to Boxer.
Module chat80 Chat-80 was a natural language system which allowed the user to interrogate a Prolog knowledge base in the domain of world geography. It was developed in the early '80s by Warren and Pereira; see http://www.aclweb.org/anthology/J82-3002.pdf...
Module cooper_storage No module docstring; 1/2 function, 1/1 class documented
Module drt No module docstring; 1/5 function, 0/1 exception, 4/20 classes documented
Module drt_glue_demo Undocumented
Module evaluate This module provides data structures for representing first-order models.
Module glue Undocumented
Module hole An implementation of the Hole Semantics model, following Blackburn and Bos, Representation and Inference for Natural Language (CSLI, 2005).
Module lfg Undocumented
Module linearlogic No module docstring; 0/1 variable, 0/1 function, 0/3 exception, 1/9 class documented
Module logic A version of first order predicate logic, built on top of the typed lambda calculus.
Module relextract Code for extracting relational triples from the ieer and conll2002 corpora.
Module skolemize No module docstring; 2/2 functions documented
Module util Utility functions for batch-processing sentences: parsing and extraction of the semantic representation of the root node of the the syntax tree, followed by evaluation of the semantic representation in a first-order model.