;;; Hey, emacs(1), this is -*- Mode: Common-Lisp; -*-, got it? ;;; ;;; PAL --- PCFG Approximation and Parsing Library for DELPH-IN ;;; ;;; Copyright (c) 2009 -- 2012 Johan Benum Evensberget (johan.benum@gmail.com) ;;; ;;; This program is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU Lesser General Public License as published by ;;; the Free Software Foundation; either version 2.1 of the License, or (at ;;; your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, but WITHOUT ;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ;;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public ;;; License for more details. ;;; (in-package :pcfg) (defparameter *include-tdf-label-paths* '(("HEAD" . (lkb::synsem lkb::local lkb::cat lkb::head)) ("CONJ" . (lkb::synsem lkb::local lkb::conj)) ("AUX" . (lkb::synsem lkb::local lkb::cat lkb::head lkb::aux)) ("AGR" . (lkb::synsem lkb::local lkb::agr lkb::png lkb::pn)) ("SPR-HEAD" . (lkb::synsem lkb::local lkb::cat lkb::val lkb::spr lkb::first lkb::local lkb::cat lkb::head)) ("SUBJ-HEAD" . (lkb::synsem lkb::local lkb::cat lkb::val lkb::subj lkb::first lkb::local lkb::cat lkb::head)) ("COMPS-HEAD" . (lkb::synsem lkb::local lkb::cat lkb::val lkb::comps lkb::first lkb::local lkb::cat lkb::head)) ("MOD-HEAD" . (lkb::synsem lkb::local lkb::cat lkb::head lkb::mod lkb::first lkb::local lkb::cat lkb::head)) ("O-COMP" . (lkb::synsem lkb::local lkb::cat lkb::val lkb::comps lkb::first lkb::opt)) ("LEX" . (lkb::synsem lkb::lex)))) #+:null (defparameter *include-tdf-lists* '(("S" (lkb::synsem lkb::local lkb::cat lkb::val lkb::spr) (lkb::local lkb::cat lkb::head)) ("U" (lkb::synsem lkb::local lkb::cat lkb::val lkb::subj) (lkb::local lkb::cat lkb::head)) ("C" (lkb::synsem lkb::local lkb::cat lkb::val lkb::comps) (lkb::local lkb::cat lkb::head)) ("M" (lkb::synsem lkb::local lkb::cat lkb::head lkb::mod) (lkb::local lkb::cat lkb::head)) ("O" (lkb::synsem lkb::local lkb::cat lkb::val lkb::comps) (lkb::opt)))) (defun create-grammar (treebanks) (setf *pcfg-symbol-table* (make-symbol-table)) (setf *tt-table* (make-hash-table :test #'equal)) (let ((items (loop for bank in treebanks for items = (tsdb::analyze bank :condition "readings > 0 && t-active == 1" :thorough '(:derivation) :gold bank) append items))) (format t "create-grammar(): Estimating a CFG from ~a items~%" (length items)) (estimate-cfg items :cfg-table *pcfg-symbol-table* :chatter t))) (defun serialize-pcfg (pcfg) (write-grammar pcfg "/tmp/grammar.pcfg") (write-symbol-table *pcfg-symbol-table* "/tmp/grammar.symbols") (write-hash-table *tt-table* "/tmp/grammar.tt")) #+:null (setf pcfg (create-grammar '("gold/erg/mrs"))) #+:null (serialize-pcfg pcfg) #+:null (read-serialized-grammar "/tmp/grammar.pcfg") #+:null (setf hypothesis (first (selectively-unpack-edges (parse '("abrams" "barked")) 42))) #+:null (maptree #'code-to-symbol (hypothesis-to-tree hypothesis))