"Intro to Pyparsing" Article at ONLamp

Bengt Richter bokr at oz.net
Mon Jan 30 17:50:15 EST 2006

On Mon, 30 Jan 2006 16:39:51 -0500, Peter Hansen <peter at engcorp.com> wrote:

>Christopher Subich wrote:
>> Using English, because that's the only language I'm fluent in, consider 
>> the sentence:
>> "The horse raced past the barn fell."
>> It's just one of many "garden path sentences," where something that 
>> occurs late in the sentence needs to trigger a reparse of the entire 
>> sentence.  
>I can't parse that at all.  Are you sure it's correct?  Aren't "raced" 
>and "fell" both trying to be verbs on the same subject?  English surely 
>doesn't allow that forbids that sort of thing. (<wink>)
The computer at CMU is pretty good at parsing. You can try it at

Here's what it did with "The horse raced past the barn fell." :

++++Time                                          0.00 seconds (81.38 total)
Found 2 linkages (2 with no P.P. violations)
  Linkage 1, cost vector = (UNUSED=0 DIS=0 AND=0 LEN=13)

    |            +----------------Ss---------------+   |
    +-----Wd-----+               +----Js----+      |   |
    |      +--Ds-+---Mv--+--MVp--+    +--Ds-+      |   |
    |      |     |       |       |    |     |      |   |
LEFT-WALL the horse.n raced.v past.p the barn.n fell.v . 

Constituent tree:

(S (NP (NP The horse)
       (VP raced
           (PP past
               (NP the barn))))
   (VP fell)

IIUC, that's the way I parse it too ;-)

(I.e., "The horse [being] raced past the barn fell.")

BTW, the online response has some clickable elements in the diagram
to get to definitions of the terms.

Bengt Richter

More information about the Python-list mailing list