;;;;;; ################################################################################# ;;;;;; ##### Lecture 2: Lexical Constructions ##### ;;;;;; ################################################################################# ;;; Evaluate the following to load FCG (CTRL-X+E) and wait until loading is finished. (asdf:operate 'asdf:load-op :fcg) ;;; Also evaluate the following lines: (in-package :fcg) (activate-monitor trace-fcg) ;; You can now open a web browser (preferrably Safari or Firefox) at http://localhost:8000/ (defparameter *construction* nil "We will use this parameter for storing a construction.") (defparameter *transient-structure->* nil "We will use this parameter for storing the meaning that needs to be expressed.") (defparameter *transient-structure<-* nil "We will use this parameter for storing information about an utterance that needs to be parsed.") ;;; INTRODUCTION ;;; -------------------------------------------------------------------------------------- ;;; In construction grammar, the basic units of linguistic information are mappings ;;; between MEANING and FORM, both to be interpreted in the broad sense: MEANING includes ;;; not only conceptual meaning, but also semantics and pragmatics. Likewise, FORM includes ;;; syntax, morphology, phonology, orthography, and so on. ;;; In Fluid Construction Grammar, we represent all linguistic information through ;;; FEATURE STRUCTURES, so a mapping between MEANING and FORM is represented using a ;;; COUPLED FEATURE STRUCTURE. "coupled-feature-structure" is also the name of a CLASS in ;;; FCG, which a.o. includes two slots called "left-pole" (in which we will put the feature ;;; structure describing MEANING) and "right-pole" (in which we will put the feature structure ;;; describing FORM): ;;; ;;; (make-instance 'coupled-feature-structure ;;; :left-pole [HERE GOES YOUR MEANING FEATURE STRUCTURE] ;;; :right-pole [HERE GOES THE FORM FEATURE STRUCTURE] ;;; ;;; Evaluate the following two instantiations of a coupled feature structure. They will be used ;;; later for producing (->) and parsing (<-) an utterance. (setf *transient-structure->* (make-instance 'coupled-feature-structure :left-pole '((meaning (mouse x))) ;; The meaning that we need to verbalize. :right-pole '((form nil)))) ;; The second feature structure has no information yet. (setf *transient-structure<-* (make-instance 'coupled-feature-structure :left-pole '((meaning NIL)) ;; We do not know the meaning yet. :right-pole '((form (string "mouse"))))) ;; This is the utterance we need to parse. ;;; As you can see, the coupled feature structures either contain an empty FORM, or an empty MEANING. ;;; During PROCESSING, additional information will be added to these coupled-feature-structures by CONSTRUCTIONS. A ;;; CONSTRUCTION can be applied in two directions: ;;; PRODUCTION: from meaning to form (or from "left" to "right") ;;; PARSING: from form to meaning (or from "right" to "left") ;;; 1. What is a construction? ;;; -------------------------- ;;; Informally speaking, a construction is also mapping between "meaning" and "form", so in FCG constructions are ;;; formalized as a subclass of a coupled-feature structure that has a couple of additional slots: ;;; - name: for giving each construction a unique ID ;;; - attributes: for adding all kind of information to a construction such as its frequency ;;; ;;; You can instantiate a construction as follows: ;;; (make-instance 'construction ;;; :name [A SYMBOL] ;;; :attributes [NIL or ANY A-LIST, e.g. '((frequency . 100) (label . lexical))] ;;; :left-pole [HERE GOES THE MEANING FEATURE STRUCTURE] ;;; :right-pole [HERE GOES THE FORM FEATURE STRUCTURE]) ;;; ;;; For convenience's sake, you can evaluate the following LISP macro that will make it easier to write basic constructions: (defmacro def-cxn (name attributes semantic-pole <--> syntactic-pole) (declare (ignorable <-->)) `(make-instance 'construction :name ',name :attributes ,(parse-attributes attributes) :left-pole ',semantic-pole :right-pole ',syntactic-pole)) ;;; Here we define our first simple construction: (setf *construction* (def-cxn mouse-cxn () ((meaning (mouse ?x))) <--> ((form (string "mouse"))))) ;;; You can now inspect the graphical visualization of the construction in the web-interface: (add-element (make-html *construction*)) (add-element (make-html *transient-structure->*)) ;;; 2. Applying a construction ;;; -------------------------- ;;; FCG has a generic function FCG-APPLY that can be used for applying a construction. The syntax ;;; is as follows: ;;; (fcg-apply construction coupled-feature-structure direction) ;;; If you want to apply a construction in PRODUCTION, pass the symbol '-> as the DIRECTION argument, ;;; if you want to parse, then use the symbol '<-. ;;; (fcg-apply *construction* *transient-structure->* '->) (fcg-apply *construction* *transient-structure<-* '<-)