__init__.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Natural Language Toolkit: Semantic Interpretation
  2. #
  3. # Copyright (C) 2001-2020 NLTK Project
  4. # Author: Ewan Klein <ewan@inf.ed.ac.uk>
  5. # URL: <http://nltk.org/>
  6. # For license information, see LICENSE.TXT
  7. """
  8. NLTK Semantic Interpretation Package
  9. This package contains classes for representing semantic structure in
  10. formulas of first-order logic and for evaluating such formulas in
  11. set-theoretic models.
  12. >>> from nltk.sem import logic
  13. >>> logic._counter._value = 0
  14. The package has two main components:
  15. - ``logic`` provides support for analyzing expressions of First
  16. Order Logic (FOL).
  17. - ``evaluate`` allows users to recursively determine truth in a
  18. model for formulas of FOL.
  19. A model consists of a domain of discourse and a valuation function,
  20. which assigns values to non-logical constants. We assume that entities
  21. in the domain are represented as strings such as ``'b1'``, ``'g1'``,
  22. etc. A ``Valuation`` is initialized with a list of (symbol, value)
  23. pairs, where values are entities, sets of entities or sets of tuples
  24. of entities.
  25. The domain of discourse can be inferred from the valuation, and model
  26. is then created with domain and valuation as parameters.
  27. >>> from nltk.sem import Valuation, Model
  28. >>> v = [('adam', 'b1'), ('betty', 'g1'), ('fido', 'd1'),
  29. ... ('girl', set(['g1', 'g2'])), ('boy', set(['b1', 'b2'])),
  30. ... ('dog', set(['d1'])),
  31. ... ('love', set([('b1', 'g1'), ('b2', 'g2'), ('g1', 'b1'), ('g2', 'b1')]))]
  32. >>> val = Valuation(v)
  33. >>> dom = val.domain
  34. >>> m = Model(dom, val)
  35. """
  36. from nltk.sem.util import parse_sents, interpret_sents, evaluate_sents, root_semrep
  37. from nltk.sem.evaluate import (
  38. Valuation,
  39. Assignment,
  40. Model,
  41. Undefined,
  42. is_rel,
  43. set2rel,
  44. arity,
  45. read_valuation,
  46. )
  47. from nltk.sem.logic import (
  48. boolean_ops,
  49. binding_ops,
  50. equality_preds,
  51. read_logic,
  52. Variable,
  53. Expression,
  54. ApplicationExpression,
  55. LogicalExpressionException,
  56. )
  57. from nltk.sem.skolemize import skolemize
  58. from nltk.sem.lfg import FStructure
  59. from nltk.sem.relextract import extract_rels, rtuple, clause
  60. from nltk.sem.boxer import Boxer
  61. from nltk.sem.drt import DrtExpression, DRS
  62. # from nltk.sem.glue import Glue
  63. # from nltk.sem.hole import HoleSemantics
  64. # from nltk.sem.cooper_storage import CooperStore
  65. # don't import chat80 as its names are too generic