;;; Patches for through, throughout, across, and along courtesy of Brigitte.

(in-package :penman)

;; new relation added by Jon 23/05/96

(penman-kb::defreified-relation Pervasive-Extent
  :is (:and penman-kb::nonparallel-extent :primitive))

(penman::annotate-concept pervasive-extent
  :doc-strings
  ("A nonparallel-extent that distinguishes between full or partial pervasion, ie, `throughout' vs. `through'" )
  :lex-items
  ())

;;SPATIAL-EXTENT-TYPE is new, and differentiates between two types of
;;spatial extends:

(system
   :name SPATIAL-EXTENT-TYPE
   :inputs (AND RELATIVE-EXTENT-PROCESS SPATIAL-PROCESS)
   :outputs ((0.5 PARALLEL-TYPE)
             (0.5 PERVASIVE-TYPE (LEXIFY MINORPROCESS THROUGHOUT)))
   :chooser SPATIAL-EXTENT-TYPE-CHOOSER
   :selector CHOICE-MASTER
   :old-feature BETWEEN
   :region PPSPATIOTEMPORAL
   :metafunction IDEATIONAL)

(chooser
   :name SPATIAL-EXTENT-TYPE-CHOOSER 
   :definition ((ASK (PERVASION-Q MINORPROCESS MINIRANGE)
                     (PERVASION (CHOOSE PERVASIVE-TYPE))
                     (NONPERVASION (CHOOSE PARALLEL-TYPE)))
                (* LP " "))
   :comments ""
   :editor ""
   :date "8-4-1992 15:55:26 at IPSI.")


;; pervasion-q edited and pervasion-q-code added by Jon 23/05/96

(askoperator
   :name PERVASION-Q
   :domain KB
   :mode IMPLEMENTED
   :parameters (RELATION RANGE)
   :english ("Does " RELATION " imply the idea of pervasion of the " RANGE " ? "
)
   :operatorcode Pervasive-Q-Code
   :parameterassociationtypes (CONCEPT CONCEPT)
   :answerset (PERVASION NONPERVASION)
   :trivialdefault NONPERVASION
   )

(defun Pervasive-Q-Code (reln range)
  "Depends on type of RELN."
  (declare (ignore range))
  (if (term-type-p reln 'pervasive-extent) 
      'pervasion 
    'nonpervasion))

;; modified input expression in Penman's EXTENT-PARALLELISM, further specification with
;; respect to dimension of object in THROUGH and ACROSS
(system    
   :name EXTENT-PARALLELISM
   :inputs PARALLEL-TYPE
   :outputs ((0.5 RELATIVE-PARALLEL (LEXIFY MINORPROCESS ALONG))
             (0.5 RELATIVE-NONPARALLEL))
   :chooser EXTENT-PARALLELISM-CHOOSER
   :selector CHOICE-MASTER
   :old-feature BETWEEN
   :region PPSPATIOTEMPORAL
   :metafunction IDEATIONAL)
  
(gate
  :name THROUGH
  :inputs (AND RELATIVE-NONPARALLEL THREE-DIMENSIONS)
  :outputs ((1.0 THROUGH (LEXIFY MINORPROCESS THROUGH)))
  :selector CHOICE-MASTER
  :region PPSPATIOTEMPORAL
  :metafunction IDEATIONAL)

(gate
  :name ACROSS
  :inputs (AND RELATIVE-NONPARALLEL (OR ZERO-DIMENSION ONE-TWO-DIMENSIONS))
  :outputs ((1.0 ACROSS (LEXIFY MINORPROCESS ACROSS)))
  :selector CHOICE-MASTER
  :region PPSPATIOTEMPORAL
  :metafunction IDEATIONAL)

;;RELATIVE-NONPARALLEL has to be added to LOCATION-DIMENSION to take care of
;;distinction between through and along.
(system
   :name LOCATION-DIMENSION
   :inputs (AND SPATIAL-PROCESS (OR NONORIENTATION-AXIS
                                    RELATIVE-NONPARALLEL))
   :outputs ((0.33333334 ZERO-DIMENSION)
             (0.33333334 ONE-TWO-DIMENSIONS)
             (0.33333334 THREE-DIMENSIONS))
   :chooser LOCATION-DIMENSION-CHOOSER
   :selector CHOICE-MASTER
   :old-feature BETWEEN
   :region PPSPATIOTEMPORAL
   :metafunction IDEATIONAL)

(reset-system-network)
(set-grammar-keyword-types)
