(in-package "KPML")
;;; File: variables.lisp
;;;
;;; Contains definitions of most of the special variables used throughout
;;; KPML, many inherited from Penman. 
;;; 3.0, 4.0. 
;;;
;;; ----------------------------------------------------------------------
;;; DEVELOPMENT NOTES:
;;;
;;; Note: from 2.0.1 changed so that there are no references
;;;       to the package USER. This is because Lucid appears to have not
;;;       to have USER and CL-USER as synonyms whereas all the other Lisps
;;;       for which 2.0.1 is supported do. This change should therefore
;;;       only affect Lucid installations.
;;;
;;; From 4.0 this file is encoded according to latin-iso8859-1
;;; because of explicit punctuation character definitions for Spanish.
;;;
;;; ----------------------------------------------------------------------
;;; First globals are now for system maintenance and version configuring...
;;; (first version, KPML: IPSI, Oct 94).
;;; 
;;; These are generally updated for each major release.
;;; ----------------------------------------------------------------------

(defvar *KPML-VERSION* :KPML)

(eval-when (:execute :load-toplevel)
  (setf *KPML-VERSION* 
    #-runtime-system :|KPML-4.1|
    #+runtime-system :|KPML-4.1 (ACL3.0 PC standalone)| 
    ))

   ;; KPML3+ subversions: Nov99
(defvar *kpml-features* '(:Aug-2009))

;;; -----------------------------------------------------------------------
;;; General configuration
;;; ----------------------------------------------------------------------

(defvar *STRATIFICATION?* nil)

  ;; more of the same for 2.0 (Jan-Apr98, Stirling).
(defvar *STANDALONE* nil)
(defvar *KPML-CREATION-TIMESTAMP* "no image created yet")

(defvar *MOTD* nil)
(defvar *STARTTOOL* nil)

(defvar *CURRENT-LANGUAGE-PACKAGE* "KPML")
(defvar *GLOSS-LANGUAGE* :english)
(defvar *STARTUP-WINDOWS* :conditional)

(defvar *DIRECTORY-DELIMITER* 
    #+unix #\/ 
    #-unix #\\)

;;; ----------------------------------------------------------------------
;;; Following appears to be an oversight/bug in Lispworks 4.0 for PC:
;;; ----------------------------------------------------------------------

#+(and :lispworks4.0 :clim-2 :harlequin-pc-lisp)
(unless (boundp 'win32-lib-clim::*default-file-filters*)
  (setf win32-lib-clim::*default-file-filters* nil))

;;; ----------------------------------------------------------------------
;;; The multilingual necessities...
;;; ----------------------------------------------------------------------

(defvar CURLAN               nil "The current language")
(defvar ALL_LANGUAGES        nil "The set of language known to KPML")
(defvar *LANGUAGES-IN-FOCUS* nil "The set of languages being worked on")

;;; ----------------------------------------------------------------------
;;; 4.0 Starting bringing in XML functionality...
;;; ----------------------------------------------------------------------

(defvar *XML-OUTPUT-STYLE-ACTIVE* nil)
(defvar *OBJECT-OUTPUT-MODE* :ascii)

;;; ----------------------------------------------------------------------
;;; 1.1: make sure that all changes to information get saved to 
;;; a protocol file that can be used in case of catastrophic 
;;; crashes prior to saving evaluated information. This is initiated
;;; by a with-open-file within startup wrapped inside kpml-i::startup.
;;; ----------------------------------------------------------------------

(defvar *KPML-EDITING-CHANGES-LOG* 
  (pathname #+unix "/tmp/kpml-editing-log"
	    #-unix "C:\\tmp\\kpml-editing-log"))
(defvar *KPML-EDITING-CHANGES-STREAM* nil)

;;; ----------------------------------------------------------------------
;;; 2.1 make sure that some base stream gets output to the Lisp Listener,
;;;     which appears not quite so straightforward in Lispworks... 
;;;     *standard-output* gets set to all sorts of curious streams while
;;;     Lispworks is doing its stuff (and *terminal-io* appears worse).
;;;     Getting the value of standard output here while we are compiling
;;;     at least gets us a stream where something appears that we can
;;;     get at somehow... (even if we have to look a bit).
;;;
   (defvar *base-output-stream* *standard-output*)
;;;
;;; ----------------------------------------------------------------------

;;; 1.1
(defvar *RECURSIVE-COPY-COMMAND* "cp -r" 
  "The recursive copy command to be used with Unix")

;;; ----------------------------------------------------------------------
;;; 2.0 The command sequence for restoring newly released patches...
;;; 2.1 default uncompression changed to gunzip...
;;; ----------------------------------------------------------------------
(defvar *KPML-PATCH-RESTORATION-COMMANDS* "cd ~A; gunzip ~A; tar xf ~A"
  "This string is used as a format string where the arguments given
   are: (i) the directory where the patches are to be, (ii) the
   compressed tar file containing the patches, and (iii) the
   uncompressed tar file containing the patches.")

(defvar *LUCID-UNCOMPRESSION-COMMAND* "gunzip")

;;; ----------------------------------------------------------------------
;;; 2.0.31
;;; User level sensitive saving of resources, a basic option for
;;; keen novices and for convenient switching between resource
;;; sets.
;;; ----------------------------------------------------------------------

(defvar *LOCAL-ROOT-OF-RESOURCES* nil)
(defvar *OTHER-ROOT-OF-RESOURCES* common-lisp-user::*root-of-resources*)

;;; ----------------------------------------------------------------------
;;; 2.1
;;; ----------------------------------------------------------------------

(defvar *SPL-SLOT-SHADOWING-FOR-HTML-REPORTS*
    '(:patch-status :selectionexpressions :structure :preselections)
  "change this to get different information in the HTML overviews")

;;; ----------------------------------------------------------------------
;;; Mailing lists and mail command to use
;;; ----------------------------------------------------------------------

(defvar *KPML-MAIL-RECIPIENT-LIST* '("bateman@uni-bremen.de"))
(defvar *MAIL-COMMAND* "mail")

;;; ----------------------------------------------------------------------
;;; Those aspects of the system that change rather slowly with time
;;; but which you only want to have to change once in any case...
;;; ----------------------------------------------------------------------

(defvar *MICRO-FUNCTION-TYPES* 
  '(function concept presentation-spec termset term))

;;; ----------------------------------------------------------------------
;;; SPL related globals...
(defvar *PLAN-GRAPHS* 
    nil "A list of the component term-graph structures in the current plan.")

(defvar *PLAN* nil "The current sentence plan")

;;; ----------------------------------------------------------------------
;;; Mouseable structured strings and output representations...

(defvar *MOUSEABLE-SENTENCE*   nil)
(defvar *MOUSEABLE-SENTENCES*  nil 
  "Mouseable record of all generation alternatives")

(defvar *MOUSE-SENSITIVE-CONSTITUENTS* :all   
  "list of grammatical features that will trigger mouse-sensitivity
   of constituents")
;; a more restricted variant would be:
;; '(nonwh-nominal) which would, for example, only do non wh nominals...

(defvar *MOUSE-SENSITIVE-TERMINALS* :all
  "list of grammatical functions that will trigger mouse-sensitivity
   of terminals")
;;; a more restricted variant would be: '(thing) for terminal things...

(defvar *FUNCTION-NUMBERING-OFFSET* 0)    ;; 2.0 for coding substructure
(defvar *MARKUP-STYLE* :html)             ;; 2.0 for html output wrappers, e.g.

;;; ----------------------------------------------------------------------
;;; 4.0 Punctuation characters...
;;;     Used in some of the string clean-up functions. Need to know which
;;;     characters in the string are opening or closing punctuation marks
;;;     so that we can do appropriate things with spaces and 
;;;     capitalization. The former are happy to have spaces after but
;;;     not before; the latter are happy to have spaces disappear after
;;;     them and to be ignore before for purposes of capitalization.

(defvar *PUNCTUATION-BAG* 
  '(#\space #\, #\. #\' #\" #\? #\! #\: #\; #\) ))
(defvar *OPENING-PUNCTUATION-BAG* 
  '(#\space #\` #\' #\" #\( #\¿ #\¡ ))

;;; ----------------------------------------------------------------------
;;; 0.9 annoying checking whether one wants the -id chooser values
;;;     to be changed or not removed by default...
;;; ----------------------------------------------------------------------

(defvar *CHECK-CHANGED-ID-VALUES* nil)

;;; ----------------------------------------------------------------------
;;; 2.0.16
;;; annoying constant check of whether something is to be saved in the
;;; environment removed by default...
;;; ----------------------------------------------------------------------

(defvar *CHECK-STORE-USER-RESPONSES* nil 
  "toggles save in environment check dialogue box")

;;; ----------------------------------------------------------------------
;;; Internal flags and parameters...
;;;
(defvar *NETWORK-UPDATED?*           nil)
(defvar *INQUIRIES-UPDATED?*         nil)
(defvar INQUIRIES-USED-IN-CHOOSER    nil)
(defvar *ACQUIRE-LEXICAL-ITEMS-MODE* nil)
(defvar *ACQUIRE-LEXICAL-ITEMS-PRESERVING-STYLE-MODE* nil)
(defvar *NEW-LEXICAL-ITEMS*          nil)
(defvar *CUMULATE-CHOOSER-ACTIVITY*  nil)
(defvar *FEATURES-USED*              nil)
(defvar *ACCUMULATE-USED-FEATURES*   nil)
(defvar DATA-FILE-STREAM             nil)

;;; 2.0 Following frequently coerced to a filename and so should not be nil
(defvar *CURRENTLY-USED-FILE*        "")       

(defvar *LAST-INQUIRY-MENTIONED*     "")
(defvar *LAST-QUESTION-MENTIONED*    nil)

;;; ----------------------------------------------------------------------
;;; Stratification...
(defvar *LIST-OF-EXTERNAL-SYSTEMS*         nil)
(defvar *EXTERNALLY-CONSTRAINED-FEATURES*  nil)
(defvar *LIST-OF-INTERGATES*               nil)
(defvar *INPUT-FEATURES-OF-INTERGATES*     nil)
(defvar *MACRO-THEMES*                     nil)
(defvar *DISCOURSE-INDIVIDUALS*            nil)

(defvar *THE-TEXT*                         "")
(defvar *GEN-STRINGS*                      "")
(defvar *CURRENT-CYCLE*)

;;; ----------------------------------------------------------------------
;;; Display stuff... some possibly redundent in KPML...

(defvar maximum-line-length       120)
(defvar current-line-length       0)
(defvar last-punc                 nil)
(defvar first-word                t)
(defvar temp-concept-string-stack nil)
(defvar concept-string-stack      nil)
(defvar item-moused               nil)

;;; ----------------------------------------------------------------------
;;; Following was lurking in the inquiry implementations file...
(defvar *VGRAPH* nil "the verbalization graph for a rank in the grammar")

;;; ----------------------------------------------------------------------
(defvar *REGIONS-WITH-NO-CHOOSERS*  nil)
(defvar *REGIONS-WITH-NO-INQUIRIES* nil)

;;; ----------------------------------------------------------------------
;;; when the following is true,  then the system  will try to use word
;;; rank  systems and below; if false,  then the system will behave as
;;; before...
(defvar *ACTIVATE-WORD-RANK-AND-BELOW* t)
(defvar *DEFAULT-NEGATION-PREFIX*      "NON")
(defvar *REGISTER-MODE* :written)

;;; ----------------------------------------------------------------------
;;; KPML additional control flags...

(defvar *BREAK-ON-NO-TARGET* nil 
  "when true, examples without target strings request strings from user")

(defvar *DEMO-MODE* nil "Set this to squash warnings (not recommended)")

;;; ----------------------------------------------------------------------
;;; Additional tracing variables, lists, etc.
;;; 0.9 individual inquiry tracing added...
(defvar *TRACED-INQUIRIES*         nil 
  "Individual inquiries to be traced")
(defvar *TRACED-CHOOSER-INQUIRIES* nil 
  "Individual inquiries to be traced only when used in particular choosers")

(defvar *TRACE-THIS-CONSTITUENT*   nil)

;;; KPML 0.9, use the following for checking example set coverage, etc.
(defvar *MONITOR-FEATURE-USE*      nil)
(defvar *CUMULATIVE-FEATURES-USED* nil)

;;; ----------------------------------------------------------------------
;;; KPML addition: 0.8
;;; John:IPSI:Feb95

;;; Previously it was assumed that all the inquiry implementations were
;;; in the Penman package, as were the SPL specifications.  If this
;;; is no longer the case, however, then these macros expand wrongly
;;; since they assume that SPL role names are in the package that
;;; the inquiry implementations were evaluated in (i.e., Penman/KPML).
;;; All references to the bear symbol have therefore been replaced
;;; by appropriate interns. The package into which they are interned
;;; is held in:
(defvar *SPL-SPECS-PACKAGE* "KPML")
;;; in case it changes anywhen.
;;; ----------------------------------------------------------------------

(defvar INQUIRY-ANSWER-IN-PRESENTATION-SPEC nil)

(defvar *PATCH-STATUS*              nil)
(defvar *CURRENT-DEFAULT-LANGUAGES* nil)
(defvar *IN-ML-REGION*              nil)

;;; ----------------------------------------------------------------------
;;; 1.0 note when there are patches... This gets set whenever
;;; there are patches, so we don't have to look if there aren't 
;;; any.
(defvar *PATCHES-EXIST* nil)

;;; ----------------------------------------------------------------------
;;; CLEANING EXAMPLE RECORDS  (Provided as patch: 1.0.17)

;;; Formerly (as inherited from Penman), it was only possible to 
;;; always add information to example records.
;;; This is useful (kind of) but not always what is required. It was
;;; designed prior to the use of SPLs where hub names are created
;;; dynamically on the fly. The previous reliance on the same hub
;;; names appearing and hence information being overwritten fails
;;; in the SPL case. Example records therefore grew whenever a particular
;;; example was regenerated. 
;;;
;;; Extension: 
;;; an additional flag is added here which causes example records to
;;; be freshly initialized each time. THIS IS ALSO NOW SET BY DEFAULT.
;;; The old behaviour can be obtained by turning this flag off: this
;;; could be used for fancy comparison of old generation runs with new
;;; ones. Comments at the end of this file indicate how this could
;;; be done fairly trivially.

(defvar *clean-example-records* T)

;;; ----------------------------------------------------------------------
(defvar *SHOW-LOADING-ACTIONS*          nil)
(defvar *MERGING-ACTIVE*                nil)
(defvar *SHOW-MERGING-ACTIONS*          nil)
(defvar *STEP-BY-STEP-MERGING-BEHAVIOR* nil)
(defvar *COLLECTED-FEATURES*            nil 
  "place to collect features while working with the interface")

;;; ----------------------------------------------------------------------
;;; Window interface flags...
(defvar WINDOW-INTERFACE-FLAG nil 
  "If true output goes to the window interface via printwindow.")
(defvar *RECOGNIZED-WINDOW-INTERFACES* '(KPML-CLIM-1.0 KPML-CLIM-2.0))
(defvar *IN-ASKWINDOW-FLAG* nil)

(defvar *INQUIRIES-TO-PAUSE-UPON*              nil)
(defvar *INQUIRY-DEFINITIONS-GIVEN*            nil)

(defvar *RESOURCE-GRAPHING-REGION-RESTRICTED?* T)
(defvar *ML-GRAPHING-MODE*                     :monolingual)
(defvar *CONTRASTIVE-GRAPHING-LANGUAGES*       nil)
(defvar *PRESERVE-SYSTEMS-IN-ML-GRAPHS*        nil)
(defvar *RESOURCE-GRAPHING-GATES-DISPLAYED?*   nil)
(defvar *REGION-EXTERNAL-LINKS-VISIBLE?*       T)
(defvar *SYSTEMIC-NOTATION*                    T)
(defvar *REGION-OVERVIEW-INFO*)

(defvar *NODES* nil "List of selected graph node contents")

(defvar *POP-UPS* '(:choosers :selection-expressions :systems))
(defvar *POSSIBLE-POP-UPS* '(:systems :selection-expressions 
				      :choosers 
				      :generated-strings
				      ))

;;; ----------------------------------------------------------------------
;;; Some global variables held in common between the old
;;; style (0.8 and before) and new style (0.9 and after) window
;;; interface.
(defvar *MERGING-TRACE-RECORDS* 
  (pathname #+unix "/tmp/" #-unix "C:\\tmp\\"))
(defvar *EXAMPLE-RUNNER-RESULTS* 
  (pathname #+unix "/tmp/" #-unix "C:\\tmp\\"))

;;; 3.2
(defvar *BASE-DEFAULT-DIRECTORY* (pathname #+unix "/tmp/" #-unix "C:\\tmp\\"))

;;; 1.1 tools (coding mode)
(defvar *coding-mode* nil)
(defvar *coding-roots* nil)
(defvar *perform-realizations* T "Can switch of realizations if required")

(defvar *patch-loading-on-language-switching* nil 
  "When languages are switched, patches are also loaded")

;;; Make inquiry implementation function recognizeable from
;;; other functions...
(defvar *inquiry-implementation-functions* (make-hash-table))

(defvar *lef* nil "If true, write-examples produces full form")

(defvar *negative-feature-prefixes* '("non" "no-" "not-"))

;;; ----------------------------------------------------------------------
;;; Variables used GRAMMAR
;;;

(defvar adjacency-constraints nil)
(defvar all-classified-functions nil)
(defvar all-conflates nil)
(defvar all-expansions nil)
(defvar all-inserts nil)
(defvar all-lexified-functions nil)
(defvar all-output-features (make-hash-table :test #'eq))
(defvar all-passes nil)
(defvar all-preselected-functions nil)
(defvar all-rule-functions nil)
(defvar before-constraints nil)
(defvar blackboard nil)
(defparameter complexity-maximum 100)  ;; increased Sep94 (morphology needs more)
(defvar computable-dependencies nil)

(defvar *CURRENT-INQUIRY-ANSWER-SOURCE* nil) ;; 2.1

;;; Following looks worrying, I wonder what it is for?!! (John:Feb95)
;;; (Actually, it can't be doing anything, since the names of these
;;;  systems have in any case changed since this was written!)
;;; It is used twice in allparts.lisp; should probably remove sometime.
(defparameter computable-dependency-declarations 
  '((process  lexicalverbtermresolution)
    (passparticiple  lexicalverbtermresolution)
    (nonfinitive  lexicalverbtermresolution)
    (finite  lexicalverbtermresolution)
    (auxstem  lexicalverbtermresolution)
    (nondeicticpresentdependent  lexicalverbtermresolution)
    (passive  lexicalverbtermresolution)
    (zauxiliarydependent  lexicalverbtermresolution)))

(defvar conflate-demons nil)
(defvar constituent-index nil)
(defparameter default-selector 'choice-master)
(defvar enterable-systems nil)
(defvar expansion-seperator nil)
(defvar feature-selections nil)
(defvar fragment-order-lsts nil)
(defvar from-feature-selections nil)
(defvar grammar-wholistic-tests nil)
(defvar last-system nil)
(defvar lexicon-wholistic-tests nil)
(defvar message-sender nil)
(defvar no-consumer-nodes nil)
(defvar no-interest-systems nil)
(defvar operators
	'(* Classify Conflate Expand Inflectify insert lexify order orderatend
		   orderatfront outclassify partition preselect))
(defvar order-at-end nil)
(defvar order-at-front nil)
(defvar ordered-pairs nil)
(defvar ordered-seperator nil)
(defvar ordering-relations nil)
(defvar path-features nil)
(defvar paths-valid nil)
(defvar show-why-system-is-firing-flag nil)
(defvar rules nil)
(defvar selectors nil)
(defvar short-network-entry-count 0)
(defvar show-preselections-flag nil)
(defvar supplement-preselections-flag nil)
(defvar system-database nil)
(defvar system-dependencies-valid nil)
(defvar System-dependencies nil)
(defvar systems nil)
(defvar systems-to-disable nil)
(defvar unordered-seperator nil)
(defvar used-systems nil)
(defvar wholes-valid nil)

;;; John:IPSI:Nov94; added. Seem to have been overlooked previously
;;; John:Bremen:March2000, probably because they don't do anything!
(defvar show-ordering-constraints nil)
(defvar show-ordering-events nil)
(defvar show-ordering-results nil)

;;;
;;; Variables used by CHOICE (Penman: this is also irrelevant for KPML)
;;;
;;;  4.0 cumulative-associations is however alive and well and continues
;;;      accumulating through pushes in basic-realizations and morph-realizations.
;;;      The list can then get very long. So we change the default behaviour
;;;      so that there is a flag:
(defvar *reinitialize-cumulative-associations* T)
;;;      which by default will reset the cumulative-associations to NIL with
;;;      each new generation.
(defvar cumulative-associations nil)

(defvar associations nil)
  ;; this is generally replaced by the following, although the values
  ;; are still often written to both...
(defvar *associations-table* (make-hash-table)) 
  ;; 3.1 extra for prosodies...
(defvar *parent-associations-table* (make-hash-table))

(defvar current-choice nil)
(defvar current-chooser nil)
(defvar global-default-ask-mode nil)
(defparameter legal-extension '(ask choiceerror choose classify copyhub defaultchoose eval identify outclassify pledge * termpledge))
(defvar pledges nil)
(defvar used-inquiry-operators nil)
(defvar inquiry-operators nil)

;;;
;;; Variables used by NIGELBASE (by what?! John:March97 :-)
;;;

(defvar *disabled-systems* nil)
(defvar regions nil)
(defvar system-enter-first-associations (make-hash-table :test #'eq))
(defvar system-selector-associations (make-hash-table :test #'eq))

;;; ----------------------------------------------------------------------
;;; Flags used by NIGELDISPLAY to control display of information in 
;;; listener window... and elsewhere in KPML...

(defvar inquiry-domain-print-flag nil)
(defvar create-boundary-at-all-choosers-flag nil)
(defparameter default-inquiry-mode 'deimplemented)
(defvar display-association-flag nil)
(defparameter english-print-length 1000)
(defvar english-trace-flag nil)
(defvar make-new-choosers-flag nil 
  "allows user to associate a new chooser with a system if systems 
   chooser is nil")
(defvar manual-guidance-flag nil)
(defvar manual-response-mode-flag nil)
(defvar non-random-lexical-selection-flag nil)
(defvar ordering-dump-flag nil)
(defvar realize-selectively-flag nil)
(defvar *realize-selectively-mode* 
    #-lispworks :graphical   ;; 2.0 a new goody (Feb98:john)
    #+lispworks :serial)     ;; 2.0 Lispworks not up to it yet... (Apr98:john)
(defvar selector-choice-flag nil
  "When using select-once allows manual specification of future
   selectors, instead of using default selector")
(defvar show-cautions-flag nil)
(defvar show-constituent-starts nil)
(defvar show-dependency-choices nil)
(defvar *show-disabled-systems-flag* nil)
(defvar show-immediate-realizations-flag nil)
(defvar show-lexical-selection nil)
(defvar show-lexical-features-flag nil)
(defvar show-ordering-events-flag nil)
(defvar show-orderings nil)
(defvar show-pledges-flag nil)
(defvar *show-pledge-checks* nil)  ;; 2.1
(defvar show-preselected-response-flag nil)
(defvar show-selection-expression-flag nil)
(defvar stop-action-flag nil)
(defvar store-to-environment-flag nil)
(defvar *show-inquiry-answer-source* nil)
(defparameter term-set-print-limit 22)
(defvar warning-stop-flag nil)
(defvar word-now-flag nil)
(defvar complete-order-info nil)
(defvar store-guidance-flag nil)
(defvar domain-implemented-value-compare-flag nil)

;;; ----------------------------------------------------------------------
;;; Counters used by NIGELINSTRUMENTATION
;;;

(defvar augmentation-count 0)
(defvar boundary-symbol nil)
(defvar caution-count 0)
(defvar cautions nil)
(defvar chooser-db nil)
(defvar *ml-chooser-db* nil)  ;; KPML
(defvar conflate-count 0)
(defvar counter-list nil)
(defvar default-ordering-count 0)
(defvar expansion-count 0)
(defvar full-counterlist nil)
(defvar matched-rules nil)
(defvar network-entry-count 0)
(defvar no-function-realization nil)
(defvar ordering-operation-count 0)
(defvar preselection-count 0)
(defvar selector-status nil)
(defvar sentence-count 0)
(defvar system-entry-count 0)
(defvar traced-systems nil)
(defvar warning-count 0)
(defvar warningstop-flag nil)
(defvar warnings nil)
(defvar word-selection-failure-count 0)
(defvar word-selection-success-count 0)

;;; ----------------------------------------------------------------------
;;; Variables used by LEXICON code
;;;
;;; THIS IS STILL HARDCODING IRREGULAR ENDING TYPES, HOWEVER, AND
;;; SO NEEDS FURTHER PARAMETERIZATION ACCORDING TO LANGUAGE...
;;; THIS IS BEGUN HERE BY MOVING SOME OF THE HARDCODED LISTS
;;; USED IN THE MORPHOLOGY CODE INTO VARIABLES...
(defvar *lexical-entry-ending-types*
  '(Es-ed S-*ed S-ed S-d *-Irr S-irr Es-irr Irr Er-est R-st *Er-*est 
	  Es S))
(defvar *lexicon-irregular-ending-types*
  '(*-Irr S-irr Es-irr Irr))

;;; 3.1 another small step towards parameterization...
(defvar *ml-lexical-entry-ending-types*
  '((:english (Es-ed S-*ed S-ed S-d *-Irr S-irr Es-irr Irr Er-est R-st *Er-*est Es S))))
(defvar *ml-lexicon-irregular-ending-types*
  '((:english (*-Irr S-irr Es-irr Irr))))

;;; 4.1 acknowledging the fact that different languages might do
;;;     rather different things in order to lexicalize...
(defvar *classifying-lexicalized-entry-language*
  '(:german :dutch))

(defun CLASSIFYING-LEXICALIZED-ENTRIES-P (language)
  (member language *classifying-lexicalized-entry-language*))
      


(defvar fixed-filter-predicate-list nil)
(defvar last-word nil)
(defvar lexical-class-defs nil)
(defvar lexical-selections nil)
(defvar max-sequences nil)
(defvar process-fn-list nil)
(defvar show-order-relations nil)
(defvar show-order-results nil)
(defvar terminal-lexical-feature-list nil)
(defvar valid-lexical-feature-list nil)
(defvar word-classes nil)
(defvar word-classes-valid nil)
(defvar words nil)

;;; ----------------------------------------------------------------------
;;; Variables used by penman-exec
;;;

(defvar penexamples (make-hash-table :test #'eq))
(defvar examples nil)
(defvar logical-form nil)
(defvar *most-recent-example* nil)
(defvar discourse-context-stored nil)
(defvar root-node nil)
(defvar v-graph nil)
(defvar q-graph nil)
(defvar identifiable nil)
(defvar priorrefs nil)
(defvar example-identifier nil)
(defvar Show-Hubname-Discrepancy-Flag nil)

;;; ----------------------------------------------------------------------
;;; Variables that replace ACCESSFNS and SuperACCESSFNS
;;;

(defvar feature-information (make-hash-table :test #'eq))
(defvar words-of-a-feature (make-hash-table :test #'eq))

;;; ----------------------------------------------------------------------
;;;Variables used by Unwind-passes0
;;;
(defvar fat nil)
(defvar blb nil)
(defvar brb nil)
(defvar whb nil)
(defvar ors nil)

;;; ----------------------------------------------------------------------
;;;variables used by constituent0
;;;
(defvar whiteboard-element nil)
(defvar bundle-for-display  nil)
;;;also used current-preselections below

;;; ----------------------------------------------------------------------
;;;variables used by compute-paths
;;;
(defvar loop-errors nil)

;;;
;;;variables used by compute-void-features
;;;
(defvar all-void-features nil)

;;;
;;; used by up-stream-systems
;;;
(defvar known-up-stream-systems nil)

;;;
;;; used by augment-preselections
;;;
(defvar new-count nil)

;;;
;;; used by the new Lex
;;;
(defvar lexicon (make-hash-table :test #'eq))

;;;
;;; used in wholistic test
;;;
(defvar all-expanded-functions nil)

;;;
;;; used in Left-to-right
;;;
(defvar function-sequence nil)

;;; ----------------------------------------------------------------------
;;; variables in the various ordering functions

(defvar sentence-tree nil)
(defvar final-orderings nil)

(defvar expand-parents nil)
(defvar terminals nil)
(defvar non-terminals nil)
(defvar expansions nil)   
(defvar constraints nil)  
(defvar conflations nil)  
(defvar terminal-conflations nil)
(defvar first-ordering nil)
(defvar dead-ends nil )   
(defvar sequences nil)
;;;;;
(defvar system-table (make-hash-table :test #'eq))
(defvar choosers (make-hash-table :test #'eq))
(defvar quiry-operators (make-hash-table :test #'eq))
(defvar *traced-systems* nil)
(defvar current-preselections nil)
(defvar whiteboard nil)
(defvar brownboard nil)
(defvar hash-table-of-all-functions (make-hash-table :test #'eq))
(defvar show-pass-hash-table (make-hash-table :test #'eq))
(defvar list-of-all-grammatical-functions nil)
(defvar new-example-loaded nil)
(defvar pause-continue-flag :continue)

(defvar preselection nil) ;;;TYG: value is temporary; shd be gotten from environment
(defvar operator-name)
(defvar hubs)
(defvar kb '(nil)) ;;;TYG: temporary starting value for test purposes
(defvar tp '(nil)) ;;;TYG: temporary starting value for test purposes
(defvar val)
(defvar example-runner-flag nil)
(defvar say-lock nil)
(defvar express-lock nil)
(defvar atomic-operation-lock nil)
(defvar *all-regions* nil)
(defvar fast-flag t 
  "when t does not sort systems ready for entry, runs faster, 
   systems entered nondeterministically.")

(defvar list-of-gates nil)
;;; 0.9 the following now does the work of the former
(defvar *gate-table* (make-hash-table))

(defvar system-output-features (make-hash-table :test #'eq)
  "the list of output features for each system, avoid run time computation")

;;; ----------------------------------------------------------------------
;;; Punctuation rules...

(defvar *pre-punctuation* nil)
(defvar *post-punctuation* nil)
(defvar *post-self-punctuation* nil)
(defvar *pre-self-punctuation* nil)        ;; Added at 4.0, Sep2002

(defvar alias-function-stack nil) ;used by whereamiidcode

;;; ----------------------------------------------------------------------
;;; Grammar dependent variables - hardwired
;;;
(defvar *tty-right-margin* 80)
(defvar *window-right-margin* 45)

;;; ----------------------------------------------------------------------
;;; John: IPSI: April 94; this list is used in tag-fn-name. Previously
;;; only went up to 40 -- with morphology, etc. in place this can now
;;; easily be superceded. So, added up to 200.

(defvar constituent-index-to-string-alist
  '((1 "#1")
    (2 "#2")
    (3 "#3")
    (4 "#4")
    (5 "#5")
    (6 "#6")
    (7 "#7")
    (8 "#8")
    (9 "#9")
    (10 "#10")
    (11 "#11")
    (12 "#12")
    (13 "#13")
    (14 "#14")
    (15 "#15")
    (16 "#16")
    (17 "#17")
    (18 "#18")
    (19 "#19")
    (20 "#20")
    (21 "#21")
    (22 "#22")
    (23 "#23")
    (24 "#24")
    (25 "#25")
    (26 "#26")
    (27 "#27")
    (28 "#28")
    (29 "#29")
    (30 "#30")
    (31 "#31")
    (32 "#32")
    (33 "#33")
    (34 "#34")
    (35 "#35")
    (36 "#36")
    (37 "#37")
    (38 "#38")
    (39 "#39")
    (40 "#40")
    (41 "#41")
    (42 "#42")
    (43 "#43")
    (44 "#44")
    (45 "#45")
    (46 "#46")
    (47 "#47")
    (48 "#48")
    (49 "#49")
    (50 "#50")
    (51 "#51")
    (52 "#52")
    (53 "#53")
    (54 "#54")
    (55 "#55")
    (56 "#56")
    (57 "#57")
    (58 "#58")
    (59 "#59")
    (60 "#60")
    (61 "#61")
    (62 "#62")
    (63 "#63")
    (64 "#64")
    (65 "#65")
    (66 "#66")
    (67 "#67")
    (68 "#68")
    (69 "#69")
    (70 "#70")
    (71 "#71")
    (72 "#72")
    (73 "#73")
    (74 "#74")
    (75 "#75")
    (76 "#76")
    (77 "#77")
    (78 "#78")
    (79 "#79")
    (80 "#80")
    (81 "#81")
    (82 "#82")
    (83 "#83")
    (84 "#84")
    (85 "#85")
    (86 "#86")
    (87 "#87")
    (88 "#88")
    (89 "#89")
    (90 "#90")
    (91 "#91")
    (92 "#92")
    (93 "#93")
    (94 "#94")
    (95 "#95")
    (96 "#96")
    (97 "#97")
    (98 "#98")
    (99 "#99")
    (100 "#100")
    (101 "#101")
    (102 "#102")
    (103 "#103")
    (104 "#104")
    (105 "#105")
    (106 "#106")
    (107 "#107")
    (108 "#108")
    (109 "#109")
    (110 "#110")
    (111 "#111")
    (112 "#112")
    (113 "#113")
    (114 "#114")
    (115 "#115")
    (116 "#116")
    (117 "#117")
    (118 "#118")
    (119 "#119")
    (120 "#120")
    (121 "#121")
    (122 "#122")
    (123 "#123")
    (124 "#124")
    (125 "#125")
    (126 "#126")
    (127 "#127")
    (128 "#128")
    (129 "#129")
    (130 "#130")
    (131 "#131")
    (132 "#132")
    (133 "#133")
    (134 "#134")
    (135 "#135")
    (136 "#136")
    (137 "#137")
    (138 "#138")
    (139 "#139")
    (140 "#140")
    (141 "#141")
    (142 "#142")
    (143 "#143")
    (144 "#144")
    (145 "#145")
    (146 "#146")
    (147 "#147")
    (148 "#148")
    (149 "#149")
    (150 "#150")
    (151 "#151")
    (152 "#152")
    (153 "#153")
    (154 "#154")
    (155 "#155")
    (156 "#156")
    (157 "#157")
    (158 "#158")
    (159 "#159")
    (160 "#160")
    (161 "#161")
    (162 "#162")
    (163 "#163")
    (164 "#164")
    (165 "#165")
    (166 "#166")
    (167 "#167")
    (168 "#168")
    (169 "#169")
    (170 "#170")
    (171 "#171")
    (172 "#172")
    (173 "#173")
    (174 "#174")
    (175 "#175")
    (176 "#176")
    (177 "#177")
    (178 "#178")
    (179 "#179")
    (180 "#180")
    (181 "#181")
    (182 "#182")
    (183 "#183")
    (184 "#184")
    (185 "#185")
    (186 "#186")
    (187 "#187")
    (188 "#188")
    (189 "#189")
    (190 "#190")
    (191 "#191")
    (192 "#192")
    (193 "#193")
    (194 "#194")
    (195 "#195")
    (196 "#196")
    (197 "#197")
    (198 "#198")
    (199 "#199")
    (200 "#200")
    ))

(eval-when (:execute :load-toplevel)
  (setf  kpml::*root-of-resources* common-lisp-user::*root-of-resources*
	 kpml::all_languages common-lisp-user::*configuration-all-languages*
	 kpml::curlan common-lisp-user::*curlan*)

  ;; following makes sure that the stratification flags are
  ;; known about, even if we are not running stratification...
  (unless 
      (boundp 'kpml::*stratification?*)
    (defvar kpml::*stratification?* nil "Not used in this KPML version"))
  (setf kpml::*stratification?* common-lisp-user::*stratification?*))

  ;; ----------------------------------------------------------------------
  ;; 3.2.47
  ;;  Added parameterized control of the example names that are created
  ;;  automatically whenever generation is of an SPL. Also added is
  ;;  control over whether we keep on accumulating new SPLs whenever
  ;;  we generate (which can then accumulate huge numbers of SPLs if
  ;;  we are running in an application) or whether we reuse SPLs so
  ;;  as not to grow huge lists. These are added as parameters to both
  ;;  SAY and ONLY-SAY. The defaults for these parameters come from 
  ;;  the following two new globals...
  ;;
(defvar *default-created-spl-name* "SPL")
(defvar *reuse-created-spls* NIL)

  ;; Following enables transliterations... (in theory: not used much yet)
  ;; 
(eval-when (load)
	   (push :translit all_languages))

;; ----------------------------------------------------------------------
;; Additions as of KPML4
;; ----------------------------------------------------------------------

  ;; Following moved from ui-clim/substrate as a few places now use it
  ;; even without the interface being present.
(defvar *STRUCTURE-GRAPH-TOP-NODE* 'sentence "Label for the top node")

