Latex for CG (SUMMARY)

Ash Asudeh asudeh at csli.stanford.edu
Sun Jun 22 23:23:02 UTC 2003


Dear all,

A number of people responded to my query about Latex for Categorial
Grammar. I would like to thank: Martin Jansche, Wesley Davidson, Roger
Levy, Shuichi Yatabe, Stefan Mueller, Michael Daniels, Jason Baldridge,
Christopher Manning, and Bob Carpenter.

I provide a summary below for those that are interested.

Thanks again,
Ash

SUMMARY:
Wes Davidson pointed out that I was confusing in my original description
of what I was looking for and he was absolutely right. What I wanted was a
package that lines up a string at the top and has the derivation proceed
downward, as in:

(1)
	Mary  prefers  corduroy			(Steedman's example)
	---- --------- --------
	 NP  (S\NP)/NP    NP
	     ---------------
		 S\NP
	-------------
	     S
		
What I was getting with prooftree.sty was:

(2)
	      prefers  corduroy			
	     --------- --------
	Mary (S\NP)/NP    NP
	---- ---------------
	 NP	 S\NP
	-------------
	     S

This isn't so bad, but most work in CCG and some work in the
Type-Logical/Lambek (in particular, Bob Carpenter's book) uses the former.
I felt that most linguists, especially those not steeped in CG, would find
the former more familiar and for large derivations the string-at-top
notation is easier to read, in my experience.

The suggestions I got from the two lists were very helpful and I thought
there may be sufficient interest for me to share them:

1. Martin Jansche, Wes Davidson, and Chris Manning each suggested that I
use Makoto Tatsuta's proof.sty. It is available at
www.ctan.org (macros/latex/contrib/proof)
or direct from the author's webpage at
http://research.nii.ac.jp/~tatsuta/proof-sty.html

This is a nice, elegant package and a good alternative to prooftree.sty
(which I find fine, though). However, I couldn't get it to behave like
(1), only like (2), which I was already getting with prooftree.sty. The
code I tried was:

\infer[<]{S}{\infer{NP}{Mary} &
  \infer[>]{NP/S}{\infer{(NP/S)/NP}{prefers} & \infer{NP}{corduroy}}}

I confess that I didn't fiddle with it a lot to try and get it to behave,
mainly because of 6 below.

Martin also suggested Bob might have something (see 5 below).

2. Roger Levy suggested that Bob Carpenter's type-logical theorem prover
might have some Latex capabilities in terms of formatting the output. It's
available at
http://www.colloquial.com/tlg/parser.html

I looked briefly, but didn't find anything, and I was really looking for
something to write my own trees in (cut out the middle parser), so I
didn't  persist (also there was 6 below).

3. Shuichi Yatabe suggested I look at CSLI's authoring package at
http://cslipublications.stanford.edu/site/authors.html

I appreciate the suggestion, but I have had a lot of frustration using
publishers' packages (mainly with Kluwer, but also a little with CSLI). As
I anticipated that this would require more mucking around than I was
prepared to do, I didn't chase it up.

4. Michael Daniels suggested I look at the ling-tex page
http://heim.ifi.uio.no/~dag/ling-tex.html

There was no mention of the kind of thing I was looking for in
ling-mac.pdf (which mainly contains pointers to packages for numbered
examples and phrase structure trees), and I didn't search the mail
archives.

5. Bob Carpenter reported that all the derivations in his book were from
an  automatic theorem-prover written in Prolog, with some post-editing.
Why? Because Tex kept blowing its stack.

6. Jason Baldridge suggested his macros, based on stuff by Mark Steedman
and others, which are available at:
http://www.iccs.informatics.ed.ac.uk/~jmb/latex/ccg.sty

There's other neat stuff there too.

Unsurprisingly, I struck gold with this. There's a lot more than what I
was looking for, but what I needed was definitely there. The basic stuff
works by using an array and is elegant and easy to use.

I include below my own version of just the bits that I needed, which
should be sufficient for many purposes (thank Jason!).

% CG derivation trees
% Adapted from Jason Baldridge's ccg.sty available at:
% http://www.iccs.informatics.ed.ac.uk/~jmb/latex/
% Baldirge acknowledges:  B. Hoffman and M. Steedman
% Modifications by Ash Asudeh

% CG's backwards and forwards slashes
\newcommand{\bs}{\backslash}
\newcommand{\fs}{/}

% The essential tree command; #1 is the number of words, #2 is the array
\newcommand{\cgtree}[2]
{ \renewcommand{\arraystretch}{.5}
  \ensuremath{
	\begin{array}[t]{*{#1}{c}}
     	#2
   	\end{array}
	}}

% Straight from ccg.sty
% centered multicolumn,
\newcommand{\mc}[2]
  {\multicolumn{#1}{c}{#2}}

% Rules, argument #1 gives the number of columns to cover.
% Adapted from ccg.sty

% Use \lxline as markup for the line under lexical entries
\newcommand{\lxline}[1]
{\mc{#1}{\hrulefill}}

% Use \uline for a simple line
% From ccg.sty
\newcommand{\uline}[1]
{\mc{#1}{\hrulefill}}

% Use \cgrule to draw a line and adorn it with the rule
% of proof/combinator (#2)
\newcommand{\cgrule}[2]
{\mc{#1}{\hrulefill\ensuremath{_{#2}}}}

%% An example, based on ccg.sty:
% \cgtree{3}{%
% {\rm Mary}&{\rm prefers}& {\rm corduroy}\\
% \lxline{1}& \lxline{1}    & \lxline{1}\\
% \it NP   &\it (NP\bs S)\fs NP &\it  NP\\
%         &     \justifies{2}\\
%         & \mc{2}{\it NP\bs S}\\
% \using{2}{<}&\\
% \mc{2}{\it S}&
% }



More information about the HPSG-L mailing list