;;; Copyright (c) 1991--2022 ;;; John Carroll, Ann Copestake, Robert Malouf, Stephan Oepen, Benjamin Waldron; ;;; see LICENSE for conditions. ;;; ;;; This is the base globals file because parameters have to be ;;; defined somewhere, but in most cases a particular set of ;;; grammar files will have their own associated parameters ;;; ;;; All functions have now been moved to user-fns.lsp (in-package :lkb) ;;; Keep track of all parameters that get defined, so we can have a way to ;;; edit them interactively ;;; ;;; We distinguish between user parameters - which can be edited interactively ;;; - and other parameters, which normally shouldn't be. ;;; To quote the LKB User Manual, user parameters "control aspects of the ;;; system which are not grammar specific, but which concern things such as ;;; font size, which are more a matter of an individual user's preferences." (defvar *lkb-user-params* nil) (defvar *lkb-params* nil) (defvar *user-params-file* nil "file where values of user params are saved") (defmacro def-lkb-parameter (var val &optional doc type) `(progn ; JAC 6-May-2023 - was eval-when (:load-toplevel :execute) but need compile-time effect ,@(if (eq type :user) `((pushnew ',var *lkb-user-params*) (setq *lkb-params* (delete ',var *lkb-params*))) `((pushnew ',var *lkb-params*) (setq *lkb-user-params* (delete ',var *lkb-user-params*)))) (defparameter ,var ,val ,@(if doc (list doc))) #+:sbcl (declaim (sb-ext:always-bound ,var)) ',var)) ;;; Type hierarchy: special features, paths and types (def-lkb-parameter *toptype* 'top "the name of the top type in the type hierarchy") (def-lkb-parameter *string-type* 'string "the name of the type which is special in that all double-quoted string type names are subtypes of it") (def-lkb-parameter *orth-path* '(orth lst)) (def-lkb-parameter *alt-orth-path* nil "an alternative location for the orthography --- needed for Aline's grammar") (def-lkb-parameter *list-tail* '(tl)) (def-lkb-parameter *list-head* '(hd)) (def-lkb-parameter *list-type* '*list*) (def-lkb-parameter *empty-list-type* '*null*) (def-lkb-parameter *non-empty-list-type* '*cons*) ; !!! undocumented and often not set correctly (def-lkb-parameter *diff-list-type* '*diff-list*) (def-lkb-parameter *diff-list-list* 'list) (def-lkb-parameter *diff-list-last* 'last) (def-lkb-parameter *head-daughter-path* '(head-dtr)) (def-lkb-parameter *head-path* '(synsem local cat head)) (def-lkb-parameter *key-daughter-path* '(key-arg)) (def-lkb-parameter *key-daughter-type* '+) ;;; ;;; chart mapping is enabled by setting *token-type* to the name of the token ;;; type (standardly, `token'). Token feature structures have type *token-type* ;;; and consist of grammar-specific bundles of properties that were input to ;;; parsing; to access individual components, there are a number of ;;; (customizable) paths. ;;; (def-lkb-parameter *token-type* nil) (def-lkb-parameter *token-form-path* nil) (def-lkb-parameter *token-id-path* nil) (def-lkb-parameter *token-from-path* nil) (def-lkb-parameter *token-to-path* nil) (def-lkb-parameter *token-postags-path* nil) (def-lkb-parameter *token-posprobs-path* nil) ;;; ;;; when token mapping is enabled, lexical entries behave similarly to grammar ;;; rules in one respect: the list of input tokens that license a lexical entry ;;; are unified into *lexicon-tokens-path*. furthermore, to give the ;;; grammarian easier access to the token in the right periphery, the last element ;;; of the tokens list is made re-entrant with *lexicon-last-token-path*. ;;; (def-lkb-parameter *lexicon-tokens-path* nil) (def-lkb-parameter *lexicon-last-token-path* nil) ;;; ;;; chart mapping rules consist of between 1 and 5 components (the minimum being ;;; a single input FS) ;;; (def-lkb-parameter *chart-mapping-context-path* '(+CONTEXT)) (def-lkb-parameter *chart-mapping-input-path* '(+INPUT)) (def-lkb-parameter *chart-mapping-output-path* '(+OUTPUT)) (def-lkb-parameter *chart-mapping-position-path* '(+POSITION)) (def-lkb-parameter *chart-mapping-jump-path* '(+JUMP)) ;;; Misc (def-lkb-parameter *lex-rule-suffix* nil "creates the inflectional rule name from the information in irregs.tab - for PAGE compatability") (def-lkb-parameter *sense-unif-fn* nil) (def-lkb-parameter *gc-before-reload* nil) ;;; Morphology (def-lkb-parameter *morph-option* :default "possible values are :default, :distinct-mphon, :external-rule-by-rule :external-partial-tree, :with-tokeniser-partial-tree, :with-tokeniser-retokenise") (def-lkb-parameter *foreign-morph-fn* nil "alternative to built in LKB morphology") ;;; Revised morphology (def-lkb-parameter *affix-type* 'affix) (def-lkb-parameter *rule-affix-feature* 'affixation) (def-lkb-parameter *affix-pattern-feature* 'pattern) (def-lkb-parameter *affix-class-feature* 'affix-class) (def-lkb-parameter *letter-set-feature* 'letters) (def-lkb-parameter *letter-set-char-feature* 'char) (def-lkb-parameter *letter-set-match-feature* 'match) (defparameter *known-cyclic-rules* nil "to allow disabling of warning messages about possible cycles - advanced users only") ;;; Parsing / generation limits, key types and features, etc (def-lkb-parameter *maximum-number-of-tasks* 200000 "limits the number of pending tasks on the parsing/generation agenda and (separately) on each edge's selective unpacking agenda") (def-lkb-parameter *maximum-number-of-edges* 2000 ; c.f. 500 in LKB User Manual p.210 "limits the size of the parsing/generation chart" :user) ;;; ;;; when unpacking, edges are a lot cheaper, as we are deterministic at this ;;; point (e.g. there will be very few failing unifications, if any). hence, ;;; impose a separate limit for unpacking, although it could be argued that we ;;; should count on top of the edges built already (like PET does). i prefer ;;; independent counting, however, since active edges (in generation at least) ;;; are also included in the edge count, but we could dispose of them when we ;;; move on into unpacking. (26-nov-04; oe) ;;; (def-lkb-parameter *unpack-edge-allowance* 2000 ; post-dates the LKB User Manual "limits the number of edges created during chart unpacking") (def-lkb-parameter *chart-limit* 100 "maximum number of tokens in a sentence to be parsed") (def-lkb-parameter *bracketing-p* nil "if set, the input may contain a partial bracketing which will be respected (currently not supported in the default, active parser)") (def-lkb-parameter *mother-feature* 0 "the feature giving the mother in a grammar rule") (def-lkb-parameter *start-symbol* 'sign "a type or instance (or a list of these) specifying the type of any valid parse" :user) (def-lkb-parameter *gen-start-symbol* 'sign "a type or instance (or a list of these) specifying the type of any valid generator derivation" :user) (def-lkb-parameter *fragment-start-symbols* nil "a type or instance (or a list of these) specifying the type of a valid derivation in fragment parsing or generation mode" :user) (def-lkb-parameter *non-idiom-root* nil "an instance which the parser unifies with each candidate parse fs to determine whether the additional idiom root condition needs to be checked") (def-lkb-parameter *feature-ordering* nil "a list of features specifying the order in which they should appear when a fs is displayed") (def-lkb-parameter *maximal-lex-rule-applications* 7 "the number of lexical rule applications which may be made before it is assumed that some rules are applying circularly") (def-lkb-parameter *deleted-daughter-features* nil "list of features not to be passed from daughter to mother when parsing or generating") (def-lkb-parameter *check-paths* nil "an alist in which the keys are feature paths that often fail - these are checked first before attempting unification") (def-lkb-parameter *check-path-count* 50 "the number of check paths actually used") (def-lkb-parameter *substantive-roots-p* nil "if set, root edges are regarded as real edges for the purposes of chart display") (def-lkb-parameter *irregular-forms-only-p* nil "if set, the parser will not parse regular spellings if there is an irregular spelling (e.g. 'eated', 'dreamed') - consider replacing with *most-specific-only-p*") (def-lkb-parameter *most-specific-only-p* nil "if set, the parser will not parse regular spellings if there is an irregular spelling (eated, dreamed) and will only accept the most specific pattern in a subrule.") (def-lkb-parameter *unknown-word-types* nil "if set, the user-fn make-unknown-word-sense-unifications should also be defined. Together they result in entries of the specified type or types being created for any unknown words which may occur in the input") (def-lkb-parameter *packing-restrictor* nil "restrictor used when parsing with ambiguity packing") (def-lkb-parameter *rule-keys* nil "an alist mapping a rule identifier to the position of the rule's key daughter") (def-lkb-parameter *spanning-only-rules* nil "list of rules constrained to only apply over the entire string") ;;; Display (def-lkb-parameter *comparison-dependencies-font-size* 12 "size of font in tree comparison (elementary dependencies in tree pane)" :user) (def-lkb-parameter *comparison-discriminant-font-size* 8 "size of font in tree comparison (discriminant pane)" :user) (def-lkb-parameter *comparison-tree-font-size* 8 "size of font in tree comparison (tree pane)" :user) (def-lkb-parameter *dialog-font-size* 12 "size of font in dialogs" :user) (def-lkb-parameter *display-type-hierarchy-on-load* t "controls whether the type hierarchy appears automatically" :user) (def-lkb-parameter *fs-type-font-size* 12 "size of font in AVMs" :user) (def-lkb-parameter *fs-title-font-size* 12 "no longer used: AVM window titles now use *fs-type-font-size*") (def-lkb-parameter *parse-tree-font-size* 12 "size of font in parse trees and generator output" :user) (def-lkb-parameter *show-lex-rules* t "if set, applications of lexical rules are shown in parse trees and chart display" :user) (def-lkb-parameter *show-morphology* t "if set, morphological structures are shown in parse trees and chart display" :user) (def-lkb-parameter *show-incomplete-lex-rule-chains* t "controls whether the parse chart does or does not show chains of lexical rule applications that are incomplete (due to a requisite rule failing to apply)") (def-lkb-parameter *summary-tree-font-size* 8 "size of font in parse tree summary" :user) (def-lkb-parameter *type-tree-font-size* 12 "size of font in type hierarchy display" :user) (def-lkb-parameter *maximum-list-pane-items* 150 "maximum number of items in a list pane") (def-lkb-parameter *lex-rule-show-one-step* t "if set, lexical rule application will be shown one step at a time") ;;; YADU (def-lkb-parameter *description-persistence* 'l "atom marking tails which should be made non-default when a description is expanded into a complete TFS") ;;; Parse tree node labels (def-lkb-parameter *simple-tree-display* nil "if set, use the simple node labelling scheme in parse trees rather than PAGE style labels") ;;; Control of PAGE-style parse tree node labels (when *simple-tree-display* is nil) ;;; the path where the name string is stored (def-lkb-parameter *label-path* '(LABEL-NAME)) ;;; the path for the meta prefix symbol (def-lkb-parameter *prefix-path* '(META-PREFIX)) ;;; the path for the meta suffix symbol (def-lkb-parameter *suffix-path* '(META-SUFFIX)) ;;; the path where the args are stored (def-lkb-parameter *args-path* '(ARGS)) ;;; the path for the recursive category (def-lkb-parameter *recursive-path* '(NON-LOCAL SLASH LIST FIRST)) ;;; the path inside the node to be unified with the recursive node (def-lkb-parameter *local-path* '(LOCAL)) ;;; the path inside the node to be unified with the label node (def-lkb-parameter *label-fs-path* '(SYNSEM)) ;;; the type for all label templates (def-lkb-parameter *label-template-type* 'label) ;;; ;;; size of static pool used to cache safe dag instances (see `dag.lsp'). ;;; ;;; if each dag instance has approximately 80 bytes, then we should be able to ;;; affort some (static) 4 MB for pool storage (assuming a pool of size ;;; 50,000). once make-dag() runs out of pool instances, new structures will ;;; be allocated dynamically (and become garbage eventually). hence, the ;;; initial pool size can be a crucial choice. ;;; ;;; though it seems tempting to allocate new pools as required, this would mean ;;; that one huge sentence could grow the image size permanently. for the time ;;; being we prefer to assume that the user choice of pool size is appropriate ;;; for what is required on average. ;;; ;;; Grammars such as the ERG could increase this parameter and then recreate ;;; the pool -- JAC 28-May-18 (def-lkb-parameter *dag-pool-size* 50000) ;;; Switch controlling TDL or path syntax (not really needed) (def-lkb-parameter *lkb-system-version* :page) ;;; Best-first processing (def-lkb-parameter *first-only-p* nil "if set, only the first parse is produced" :user) (def-lkb-parameter *gen-first-only-p* nil "if set, only the first realization is produced" :user) ;;; Compare facility (def-lkb-parameter *discriminant-path* '(synsem local cont key)) (defparameter *current-grammar-load-file* nil "not user settable - has to be here because it's used in lisp specific stuff as well as elsewhere") (defvar *lexicon* nil) (defvar *leaf-types* nil) (defvar *current-language* nil) ;;; MRS interaction control (defvar *mrs-loaded* nil) ;;; Generator globals (defparameter *semantics-index-path* '(synsem local cont index) "path used by generator to index chart") (defparameter *alt-semantics-index-path* nil "alternative path used by generator to index chart --- needed for Aline's grammar") (defparameter *intersective-rule-names* nil "names of rules that introduce intersective modifiers") (defparameter *duplicate-lex-ids* nil "temporary expedient to avoid generating dual forms") ;;; ;;; temporary expedient: allow the ERG to not use select rules (currently, ones ;;; putting on punctuation recursively) in generation. (20-may-05; dpf & oe) ;;; temporarily, provide a similar mechanism for parsing. (2-nov-12; oe) ;; (defparameter *gen-ignore-rules* nil) (defparameter *parse-ignore-rules* nil) ;;; RMRS interactive globals (def-lkb-parameter *pos-sensitive-rmrs-p* nil "controls whether the interactive RMRS comparison is sensitive to character position") (def-lkb-parameter *lexdb-params* nil "parameter settings for lexical database" :user) (defparameter *recording-word* nil "if used, this is set to a feature which should occur in the MRS relation with value *toptype*") (def-lkb-parameter *show-spelling-rules* t "if set, spelling rule (if it exists) is shown when displaying a lexical rule" :user) ;;; 'ORIGSTR (def-lkb-parameter *characterize-p* t "if set, CFROM/CTO character pointers are enabled")